A Grammar of Graphics

STAT 20: Introduction to Probability and Statistics

Warmup quetions

What are the aesthetics and geometry of this plot?

  • Bill length is mapped to the x
  • Species is mapped to the y
  • Uses boxplot geometry.

What code was used to make this plot?

ggplot(penguins, aes(x = island, fill = island)) + geom_bar()

What are the aesthetics and geometry of this plot?

Global infectious disease prevalence in 1989:

A bubble chart showing the prevalence of different infectious diseases. Each disease is represented by a bubble, its size is mapped to the prevalence, and its biological family is mapped to color. The largest bubble is labeled HIV and is green, representing viruses.

Color is mapped to taxonomic family, size is mapped to prevalence, the diseases are represented using the point geometry.

Concept Activity

You will be watching a 2.5 minute video of a presentation by a scientist, Hans Rosling, who studied global public health. He presents data visualizations depicting the change in life expectancy and family size over several decades in the 20th century.

On a piece of note paper:

  • Sketch out the data frame used to create the graphic and add the names of the variables.
  • List the aesthetic attributes used to encode the data in the graphic.
  • Identify the geometry used in the plot.

Please turn to your neighbors and…

Discuss what you came up with in terms of . . .

  • the variables present in the data frame
  • the aesthetic attributes used to encode that data in the plot
  • the geometry
01:00

What were the variables and aesthetic attributes?

Visual Cues / Aesthetics

  • Location along the x-axis
  • Location along the y-axis
  • Size of point
  • Color of point
  • Time (animation)

Variables

  • Fertility rate
  • Life expectancy
  • Population
  • Region
  • Year

What did the data frame look like?

What was the unit of observation? What were the variables? What were their type?

Unit of observation

  • A country in a given year

Variables

  • Fertility rate (continuous)
  • Life expectancy (continuous)
  • Population (continuous)
  • Region (nominal)
  • Year (discrete)

What geometry is used to represent the observations?

  • Points

Worksheet: A Grammar of Graphics

If you finish early, get started on the new lab: Flights I.

30:00