Adding title with dynamic name

To create R Scatterplot Chart, Add a sub-title: 

  1. We use the additional function, In ggplot we add the data set “mtcars” with this adding ‘aes’, ‘geom_point’.
  2. Use the Title, Caption, Subtitle.

Example: 

R




# Loading ggplot2 package
library(ggplot2)
     
# Creating scatterplot with fitted values.
# An additional function stst_smooth
# is used for linear regression.
new_graph<-ggplot(mtcars, aes(x = log(mpg),
                              y = log(drat))) +
                    geom_point(aes(color = factor(gear))) +
                    stat_smooth(method = "lm",
                                col = "#C42126",
                    se = FALSE, size = 1)
 
# in above example lm is used for linear regression
# and se stands for standard error.
# Adding title with dynamic name
new_graph + labs(
        title = "Relation between Mile per hours and drat",
        subtitle = "Relationship break down by gear class",
        caption = "Authors own computation"
)


Output:

Scatter plots in R Language

Scatter plots in R Language

A scatter plot is a set of dotted points representing individual data pieces on the horizontal and vertical axis. In a graph in which the values of two variables are plotted along the X-axis and Y-axis, the pattern of the resulting points reveals a correlation between them.

Similar Reads

R – Scatter plots

We can create a scatter plot in R Programming Language using the plot() function....

Simple Scatterplot Chart

In order to create Scatterplot Chart:...

Creating a Scatterplot Graph

...

Scatterplot Matrices

In order to create an R Scatterplot graph:...

Scatterplot with fitted values

...

Adding title with dynamic name

When we have two or more variables and we want to correlate between one variable and others so we use a R scatterplot matrix....

3D Scatterplots

...