title of th graph and y axis label
even after entering the code i am unable to get the title of the graph and the label to y axis


R Introduction-to-ggplot2 03-04 min 50-60 sec 29-01-21, 1:07 p.m. fiza.j

Answers:

For "plot()" function kindly refer to the following example for adding title and label -

plot(1:10, main = "Example plot", xlab = "X values", ylab = "Y values")

For "ggplot()" function kindly refer to the following for the same -

library(ggplot2)
ggplot(as.data.frame(matrix(1:20,nrow = 10,ncol = 2))) + geom_point(aes(x=V1,y=V2))+labs(x="X label", y="Y label", title="Plot title")

In the "plot()" function, parameters "xlab", "ylab" and "main" are used to add axis labels and title respectively, whereas in "ggplot()" we obtain labels and title by making use of "labs()" function as shown above.
29-01-21, 1:19 p.m. chrl3hr5@gmail.com


Click here to reply/comment online