Building a scatterplot
ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
geom_line() +
theme(legend.position = "none")
![](bookclub-ggplot2_01_files/figure-html/unnamed-chunk-114-1.png)
ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
geom_bar(stat = "identity", position = "identity", fill = NA) +
theme(legend.position = "none")
![](bookclub-ggplot2_01_files/figure-html/unnamed-chunk-115-1.png)
ggplot(mpg, aes(displ, hwy, colour = factor(cyl))) +
geom_point() +
geom_smooth(method = "lm") +
labs(title = "What type of graph would you call this?", subtitle = "Notice the defaults of ggplot2") +
theme(plot.title = element_text(size = 15, color =
"firebrick", face = "bold", hjust = .5)) +
theme(plot.subtitle = element_text(hjust = .5))
![](bookclub-ggplot2_01_files/figure-html/unnamed-chunk-116-1.png)