I made a scatter plot and then added a regression line. I'm new in ggplot2
and I didn't understand so well how to add a legend. I want a circle like the scater plot saying "data", and a line saying "regression". How can I do this?
library(ggplot2)
ggplot(mpg, aes(displ, cty)) + geom_point(shape = 1) +
stat_smooth(method = "lm", formula = y ~ x, se = FALSE, colour = 1, size = 0.5) +
theme_classic() + theme(panel.border = element_rect(colour = "black", fill=NA),
aspect.ratio = 1, axis.text = element_text(colour = 1, size = 12))
And I want something like: