
H. Sherry Zhang
Department of Statistics and Data Sciences
University of Texas at Austin
library(usethis) create_from_github("SDS322E-26FALL/0403-viz5", fork = FALSE)
dive deeper into color use in data visualization
ggthemesThey are perceptually uniform: meaning that values close to each other have similar-appearing colors and values far away from each other have more different-appearing colors, consistently across the range of values.
They are robust to colorblindness, so that the above properties hold true for people with common forms of colorblindness, as well as in grey scale printing.
The rainbow palette is not uniformly perceived.
The severity of influenza in Germany in week 8, 2019.
The original color palette (left) is the classic rainbow ranging from “normal” (blue) to “strongly increased” (red).
normal
tritanopia: reduced sensitivity to blue light (extremely rare)
protanopia: reduced sensitivity to red light
deuteranopia: reduced sensitivity to green light (most common)
The rainbow palette

The viridis palette

Color blindness affects about 8% of all males and 0.5% of all females!
Normal

Deuteranopia

Protanopia

Tritanopia

The rainbow color palette is also not color blind-friendly because baseline color (blue) gets emphasized with deuteranopia and protanopia.
normal
tritanopia
protanopia
deuteranopia (most common)
Three types of color schemes designed for different types of data:
Qualitative: for categorical information, i.e., where no particular ordering of categories is available and every color should receive the same perceptual weight.
Sequential: for ordered/numeric information, i.e., going from high to low (or vice versa).
Diverging: for ordered/numeric information around a central neutral value, i.e., where colors diverge from neutral to two extremes.
New package: ggthemes has many cute themes, scales, and geometries that worth checking out.

To use ggthemes, you need to install it first using install.packages("ggthemes") in the console, and then load it using library(ggthemes) in the script.
This is a plot I show you in week1 hello-world.pdf. Can you use the mtcars data with things you’ve learnt from ggplot2 to create the exact same plot?
There are some hints in the next slides to guide you make this plot step-by-step.
Base plot: Start with a base plot that map the variables in mtcars to the x, y-axis, color, and facet.
Color: The color seems to be mapped to a continuous value. Is it the best choice? How would you change it? What’s the scale_xxx_xxx() function to change to a different color palette.
Facet: The facet header (0 and 1) are not informative, how would you change it. Maybe we can recode 0 and 1 to its actual meaning. How would you do that?
Labels: Use a more informative x and y axis title, and legend name
Theme: Play around with theme and arrange the legend position to bottom