Key Things to Remember

ggplot2 provides unlimited visualization customization

What to Remember from this Section

ggplot2 allows you to:

  1. Think about your graphics via layers
  2. Apply an organized grammar of graphics for visualization development
What you'll see here is just the beginning! See more at

What to Remember from this Section

Syntax for ggplot2 visualizations will look like:


ggplot(data = mpg, aes(x = displ, y = hwy)) +
        geom_point(aes(color = class)) +
        xlab("Engine Displacement (liters)") +
        ylab("Highway Mileage") +
        ggtitle("Fuel Economy vs. Engine Displacement") +

Resources Used…

Load these packages to follow along with this tutorial


Import the following data sets from the data folder

supermarket <- read_excel("data/Supermarket Transactions.xlsx", sheet = "Data")
facebook <- read.delim("data/facebook.tsv")
reddit <- read.csv("data/reddit.csv")
race <- read.csv("data/race-comparison.csv")

Fundamentals of ggplot2

First Layer is, well, boring

ggplot(data = supermarket)
ggplot(data = supermarket, aes(x = `Purchase Date`, y = Revenue))