Adding title with dynamic name
To create R Scatterplot Chart, Add a sub-title:
- We use the additional function, In ggplot we add the data set “mtcars” with this adding ‘aes’, ‘geom_point’.
- 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
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.