Choosing a visual and themes

Dr. Nathaniel Cline

Agenda

1

Project Topic, Audience, and Data

2

Choosing a Visual

3

Themes in ggplot

Choosing a visual

How do we choose?

  • We have talked about visualizations of data in lots of contexts

  • But if you are past the exploratory phase, and now trying to communicate to an audience, what are the merits of using one visualization over another?

  • Your reading covered the main types of visualizations we see in the wild

Core types of visualizations

  • Simple text

  • Table

  • Heat map

  • Scatter plot

  • Line

  • Slope graph

  • Bar charts

    • vertical, horizontal, stacked, 100% stacked
  • Waterfall

  • Waffle chart

  • And more!

20%

of children had a

traditional stay-at-home mom

in 2012, compared to 41% in 1970

Tables

  • Tables are meant to be read

    • not great for presentations
  • Tables make it easy to look up individual values, or pairs of values

    • harder to see patterns
  • As a general rule, light and minimal borders are better

Heatmaps

Scatterplots

Line graphs

Slope graphs

Bar charts

  • good for categorical data

  • Usually we want to kep Y-axis at zero (not necessarily true for lines!)

  • class vertical is good for just a couple data series

  • Stacked vertical can be hard to judge - put key variable on bottom

  • horizontal good for long category names, direct eyes to names first

Waffle

Critique

Practice

Use the handouts for today to practice choosing the right visual.

Themes

  • The theme function is magic!

  • The graphs on the following slides were all made using essentially the same base graph with different themes applied

Minimal

Code
satgpa <- satgpa

ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#B22222") +
  labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+ 
  theme_minimal()

Economist

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#B22222") +
  labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+
  theme_economist()

Five Thirty Eight

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#B22222") +
  labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+ 
  theme_fivethirtyeight()

WSJ

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#B22222") +
  labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+
  theme_wsj()

HRBR FT

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = ft_cols$yellow)+ labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+  theme_ft_rc()

HRBR Ipsum

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point()+ labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+  theme_ipsum()

BBC

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#B22222") +
  labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+
  bbc_style()

Barbie

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#d74ea2ff")+ labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+  theme_barbie()

Game of Thrones

Code
ggplot(satgpa, aes(x = sat_sum, y = fy_gpa)) +
  geom_point(color = "#8C4522")+ labs(title = "Do SAT Scores predict First-Year GPA?",
       x = "SAT Score",
       y = "First-Year GPA")+  theme_gameofthrones()

Theme elements

In addition to applying pre-set themes, the theme function can also alter most of the elements of your graph outside of plot type and aes assignment.

For next time

  • Read “Reducing Clutter”
  • Complete the “themes” assignment in Rstudio cloud