A Layered Grammar of Graphics

Laura Henze1, Tristan Zook2

Department of Data Science; 1 Department of Biochemistry; 2 Department of Mathematics/Computer Science, Lawrence University

Introduction

Leland Wilkinson’s Grammar of Graphics proposed a way to break graphics in to a set of common building blocks. Hadley Wickham’s A Layered Grammar of Graphics transformed data visualization by expanding on these ideas.

From Wilkinson to Wickham

The paper extends Leland Wilkinson’s Grammar of Graphics by:

  • Introducing a layered framework
  • Embedding the grammar in R
  • Creating a consistent syntax
  • Making graphics easier to build and extend

This allows for high levels of control over increasingly complex graphics.













The Grammar of Graphics

Every graphic is built from a combination of:

  • Data
  • Aesthetic Mappings
  • Geometric Objects
  • Statistical Transformations
  • Scales
  • Coordinate Systems
  • Faceting













Building a Plot

The Simplest Grammar

Components

Component Example
Data diamonds_sample
Aesthetics carat to x, price to y
Geometry points
Scale continuous
Coordinates Cartesian

Layers: Wickham’s Key Innovation

Building Graphics Layer-by-Layer

Layers Added

  1. Data
  2. Point geometry
  3. Statistical smoothing
  4. Log-transformed scales

This example comes directly from the paper’s discussion of defaults and layering.



Histogram = Statistic + Geometry

The power in this grammar comes from control. A histogram is a good example.

It combines:

  • A binning statistic
  • A bar geometry

Separating statistics from geometries makes it easy to create new graphical forms.






Coordinate Systems

Bar Chart + Polar Coordinates = Pie Chart

This example illustrates one of the paper’s most powerful ideas:

Changing the coordinate system can transform one graphic into another without changing the underlying data.






Impact on Data Science

Why This Paper Was Revolutionary

The Grammar of Graphics introduced:

  • A unified framework
  • Reproducible graphics
  • Consistent syntax
  • Extensible visualizations
  • Easier communication of results

These ideas continue to influence modern visualization systems far beyond R.


Limitations

Challenges

  • Initial learning curve
  • Abstract concepts for beginners
  • Some specialized graphics require extensions
  • Focuses more on construction than perception

Lasting Legacy

Today the Grammar of Graphics influences:

  • ggplot2
  • The tidyverse ecosystem
  • Interactive visualization tools
  • Data science education
  • Visualization libraries in other languages

More than a decade after publication, it remains one of the most influential papers in statistical computing.


References

Wickham, H. (2010). A Layered Grammar of Graphics. Journal of Computational and Graphical Statistics, 19(1), 3–28.

Wilkinson, L. (2005). The Grammar of Graphics. Springer.