ggplot2 cheat sheet
ggplot2 cheat sheet
Intro to ggplot2 Change shape or size of points (cont) Example - add lines to a scatterplot
Basic scatterplots
library(ggplot2)
library(gridExtra)
Add lines to scatterplot
mtc <- mtcars
#connect points with line
# Basic scatterplot
p1 + geom_point(color="blue") + geom_line()
p1 <- ggplot(mtc, aes(x = hp, y = mpg))
#add regression line
# Print plot with default points
p1 + geom_point(color="red") +
p1 + geom_point()
geom_smooth(method = "lm", se = TRUE)
Example - change size of points
Change color of points #add vertical line