The grammar of graphics

Introduction to Data Visualization with ggplot2

Rick Scavetta

Founder, Scavetta Academy

The quick brown fox jumps over the lazy dog

Introduction to Data Visualization with ggplot2

The quick brown fox jumps over the lazy dog

Introduction to Data Visualization with ggplot2

Grammar of graphics

  • Plotting framework
  • Leland Wilkinson, Grammar of Graphics, 1999
  • 2 principles
    • Graphics = distinct layers of grammatical elements
    • Meaningful plots through aesthetic mappings

Introduction to Data Visualization with ggplot2

The three essential grammatical elements

Element Description
Data The data-set being plotted.
Aesthetics The scales onto which we map our data.
Geometries The visual elements used for our data.
Introduction to Data Visualization with ggplot2

Course 1: core competency

Element Description
Data The data-set being plotted.
Aesthetics The scales onto which we map our data.
Geometries The visual elements used for our data.
Themes All non-data ink.
Introduction to Data Visualization with ggplot2

The seven grammatical elements

Element Description
Data The data-set being plotted.
Aesthetics The scales onto which we map our data.
Geometries The visual elements used for our data.
Themes All non-data ink.
Statistics Representations of our data to aid understanding.
Coordinates The space on which the data will be plotted.
Facets Plotting small multiples.
Introduction to Data Visualization with ggplot2

Jargon for each element

Introduction to Data Visualization with ggplot2

Course 2: Tools for EDA

  • Remaining 3 layers
  • Best practices for Data Viz
Introduction to Data Visualization with ggplot2

Let's practice!

Introduction to Data Visualization with ggplot2

Preparing Video For Download...