time · figure 8. 30 in alberto cairo's the truthful art: map of the spread of walmart by...

31
Time Session 11 PMAP 8921: Data Visualization with R Andrew Young School of Policy Studies May 2020 1 / 31

Upload: others

Post on 04-Aug-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time

Session 11PMAP 8921: Data Visualization with R

Andrew Young School of Policy StudiesMay 2020

1 / 31

Page 2: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Plan for today

Axis issues

Visualizing time

Starting, ending,and decomposing time

2 / 31

Page 3: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Axis issues

3 / 31

Page 4: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Is truncating the y-axis misleading?

4 / 31

Page 5: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Don't be too extreme!

It is actually more legal totruncate the y-axis than you might think!

When small movements matter

When the scale itself is distorted

When zero values are impossible

5 / 31

Page 6: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

When is it okay to truncate?When small movements matter

6 / 31

Page 7: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

When is it okay to truncate?When the scale itself is distorted

7 / 31

Page 8: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

When is it okay to truncate?When zero values are impossible

8 / 31

Page 9: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Never on bar charts

9 / 31

Page 10: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Zero is okay too!

Just because you don't have to start at 0doesn't mean you should never start at 0

It's often a good idea!

10 / 31

Page 11: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Keep axis scales consistent

FOX affiliate in Colorado reporting on COVID-19 cases

11 / 31

Page 12: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Keep axis scales consistent 

12 / 31

Page 13: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Don’t impute across categories

13 / 31

Page 14: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Visualizing time

14 / 31

Page 15: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Showing changes over timeTime is just a variable that can be mapped to an aesthetic

Can be used as x, y, color, fill, facet, and even animation

Can use all sorts of geom s:lines, columns, points, heatmaps, densities, maps, etc.

In general, follow reading conventions to show time progression:

→ & ↓15 / 31

Page 16: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Front page of the New York Times, May 9, 2020

Time on x-axis + geom_line/col()

16 / 31

Page 17: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time on x-axis + geom_tile()

Figure 8.28 in Alberto Cairo's The Truthful Art: Heat map by Jorge Camões

17 / 31

Page 18: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time on y-axis + geom_density()

18 / 31

Page 19: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time in animation + geom_point()

19 / 31

Page 20: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time in maps

Figure 8.30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões20 / 31

Page 21: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Time in geom_col() + small multiples

Kieran Healy, “The Kitchen Counter Observatory”

21 / 31

Page 22: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Don't go wild with time mapping!

Tornado plot: When a curve crosses the left of the central axis, the number of deaths per day falls22 / 31

Page 23: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Interpreting tornado plots

23 / 31

Page 24: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Better with multiple plots

24 / 31

Page 25: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Starting, ending,and decomposing time

25 / 31

Page 26: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

You always have to choosea start and end point

Start and end at reasonable times thathelp maintain the context of the story

26 / 31

Page 27: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Measles vaccine was pretty effective!

27 / 31

Page 28: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Measles vaccine was incredible!

28 / 31

Page 29: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

SeasonalityDon't mistake seasonality for actual trends

29 / 31

Page 30: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Decomposition

30 / 31

Page 31: Time · Figure 8. 30 in Alberto Cairo's The Truthful Art: Map of the spread of Walmart by Jorge Camões ÿ x . Time in geom_col() + small multiples Kieran Healy, “ The Kitchen Counter

Birthday decomposition

Cover of Andrew Gelman, et al., Bayesian Data Analysis31 / 31