3 Introductory Data Visualization with ggplot
This chapter covers
- What the ggplot R package is and how it can be used to create plots from tabular data
- Creating a scatterplot from a dataset, using different aesthetic choices (e.g., shapes, color, and more)
- Using faceted plots: multiple subplots that facilitate comparisons across groups of data
- Customizing text in key plot elements
- Modifying the placement of automatically generated legends
- Alternating between transforming data with dplyr and visualizing data with ggplot
In the previous chapter, it was proposed that data visualization is a useful process for generating insights. It is often necessary to transform data before it’s ready for plotting, and, the dplyr functions we just learned about make those transformations possible. Now, we will learn about how to create beautiful and informative plots with ggplot (actually called ggplot2 but cited throughout this book more simply as ggplot). While ggplot provides functionality to create a wide selection of plot types, we will begin by focusing on a single type of plot: the scatterplot.