Effective explanatory plots

Introduction to Data Visualization with ggplot2

Rick Scavetta

Founder, Scavetta Academy

Our goal, an effective explanatory plot

Introduction to Data Visualization with ggplot2

Complete data

dplyr::glimpse(gm2007_full)
Observations: 142
Variables: 3
$ country   <fct> "Afghanistan", "Albania", "Algeria", "Angola", "Argentina", "Au...
$ lifeExp   <dbl> 43.828, 76.423, 72.301, 42.731, 75.320, 81.235, 79.829, 75.635,...
$ continent <fct> Asia, Europe, Africa, Africa, Americas, Oceania, Europe, Asia, ...
1 We would begin with our complete data set, which contains three variables for 142 countries.
Introduction to Data Visualization with ggplot2

First exploratory plots - distributions

ggplot(gm2007_full, aes(lifeExp)) +
  geom_histogram()

Introduction to Data Visualization with ggplot2

First exploratory plots - distributions

ggplot(gm2007_full_arranged, 
        aes(index, lifeExp)) +
  geom_point()

Introduction to Data Visualization with ggplot2

First exploratory plots - distributions

ggplot(gm2007_full_arranged, 
        aes(index, lifeExp, col = continent)) +
  geom_point()

Introduction to Data Visualization with ggplot2

Our data

dplyr::glimpse(gm2007)
Observations: 20
Variables: 3
$ country   <fct> "Swaziland", "Mozambique", "Zambia", "Sierra Leone", "Lesotho...
$ lifeExp   <dbl> 39.613, 42.082, 42.384, 42.568, 42.592, 42.731, 43.487, 43.82...
$ continent <fct> Africa, Africa, Africa, Africa, Africa, Africa, Africa, Asia,...
> 
Introduction to Data Visualization with ggplot2

Introduction to Data Visualization with ggplot2

Use intuitive and attractive geoms

Introduction to Data Visualization with ggplot2

Add text labels to your plot

Introduction to Data Visualization with ggplot2

Use appropriate scales

Introduction to Data Visualization with ggplot2

Add useful titles and citations

Introduction to Data Visualization with ggplot2

Remove non-data ink

Introduction to Data Visualization with ggplot2

Add threshold lines

Introduction to Data Visualization with ggplot2

Add informative text

Introduction to Data Visualization with ggplot2

Add embellishments

Introduction to Data Visualization with ggplot2

Let's practice!

Introduction to Data Visualization with ggplot2

Preparing Video For Download...