4.2 Grammar components & ggplot2 (1)

  • Let’s go into detail (Wickham 2016, 4–5)
  • Data & aesthetic mappings
    • data you want to visualize
    • aesthetic mappings: describe how variables are mapped to aesthetic attributes that you can perceive
  • Layers
    • Geometric objects (geoms): what you actually see on the plot: points, lines, etc.
    • Statistical transformations (stats): Summarize data in many useful ways (e.g., LM)
  • Scales: map values in the data space to values in an aesthetic space
    • e.g., color, size or shape
    • Scales draw legend or axes (allow us to decode graph)
  • Coordinate system (coord): describes how data coordinates are mapped to plane of graphic22
    • Provides axes/gridlines to make it possible to read the graph
  • Faceting specification: how to break up data and visualize subsets
  • Theme: Control finer points of display (e.g., font, background color etc.)


Wickham, Hadley. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer.

  1. Normally Cartesian.