Grammar of graphics

Lecture 3

Dr. Mine Çetinkaya-Rundel

Duke University
STA 199 - Fall 2022

9/6/22

Warm up

Announcements

  • Office hours start this week
  • “Graded” AEs also start this week – commit and push to your repo within 3 days of AE

Examining data visualization

Discuss the following for the visualization.

  • What is the visualization trying to show?

  • What is effective, i.e. what is done well?

  • What is ineffective, i.e. what could be improved?

  • What are you curious about after looking at the visualization?

04:00

Source: Twitter

Questions from the prepare materials?

Application exercise

ae-01

  • Go to the course GitHub org and find your ae-01 (repo name will be suffixed with your GitHub name).
  • Clone the repo in your container, open the Quarto document in the repo, and follow along and complete the exercises.
  • Render, commit, and push your edits by the AE deadline – 3 days from today.

Recap of AE

  • Construct plots with ggplot().
  • Layers of ggplots are separated by +s.
  • The formula is (almost) always as follows:
ggplot(DATA, aes(x = X-VAR, y = Y-VAR, ...)) +
  geom_XXX()
  • Aesthetic attributes of a geometries (color, size, transparency, etc.) can be mapped to variables in the data or set by the user, e.g. color = binary vs. color = "pink".
  • Use facet_wrap() when faceting (creating small multiples) by one variable and facet_grid() when faceting by two variables.