Aesthetics best practices

Introduction to Data Visualization with ggplot2

Rick Scavetta

Founder, Scavetta Academy

Which aesthetics?

  • Use your creative know-how, and
  • Follow some clear guidelines
  • Jacques Bertin
    • The Semiology of Graphics, 1967
  • William Cleveland
    • The Elements of Graphing Data, 1985
    • Visualizing Data, 1993
Introduction to Data Visualization with ggplot2

Form follows function

Introduction to Data Visualization with ggplot2

Form follows function

Function

Primary:

  • Accurate and efficient representations

Secondary:

  • Visually appealing, beautiful plots

Guiding principles

Never:

  • Misrepresent or obscure data
  • Confuse viewers with complexity

Always:

  • Consider the audience and purpose of every plot
Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Extracting information from Data

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

The best choices for aesthetics

  • Efficient
    • Provides a faster overview than numeric summaries
  • Accurate
    • Minimizes information loss
Introduction to Data Visualization with ggplot2

Aesthetics - continuous variables

ggplot(iris, aes(x = Sepal.Length,
                 y = Sepal.Width,
                 color = Species)) + 
  geom_point()

Introduction to Data Visualization with ggplot2

Aesthetics - continuous variables

ggplot(iris, aes(color = Sepal.Length,
                 y = Sepal.Width,
                 x = Species)) + 
  geom_point()

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Three iris scatter plots

Introduction to Data Visualization with ggplot2

Three iris scatter plots, unaligned y-axes

Introduction to Data Visualization with ggplot2

Single faceted plot, common y-axis

Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Aesthetics - categorical variables

ggplot(iris, aes(x = Sepal.Length,
                 y = Sepal.Width, 
                 col = Species)) + 
  geom_point()

Introduction to Data Visualization with ggplot2

Aesthetics - categorical variables

ggplot(iris, aes(x = Sepal.Length, 
                 y = Sepal.Width, 
                 col = Species)) + 
  geom_point(position = "jitter", 
             alpha = 0.5)

Introduction to Data Visualization with ggplot2

Now it's your turn

Introduction to Data Visualization with ggplot2

Preparing Video For Download...