1. Distinguish categories (qualitative) |
![]() |
Palette name: Okabe-Ito
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: ColorBrewer Set1
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: ColorBrewer Set3
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
1. Distinguish categories (qualitative) |
![]() |
2. Represent numeric values (sequential) |
![]() |
Palette name: Viridis
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: Inferno
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: Cividis
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
1. Distinguish categories (qualitative) |
![]() |
2. Represent numeric values (sequential) |
![]() |
3. Represent numeric values (diverging) |
![]() |
Palette name: ColorBrewer PiYG
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: Carto Earth
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: Blue-Red
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
1. Distinguish categories (qualitative) |
![]() |
2. Represent numeric values (sequential) |
![]() |
3. Represent numeric values (diverging) |
![]() |
4. Highlight |
![]() |
Palette name: Grays with accents
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: Okabe-Ito accent
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
Palette name: ColorBrewer accent
Figure redrawn from Claus O. Wilke. Fundamentals of Data Visualization. O'Reilly, 2019.
1. Distinguish categories (qualitative) |
![]() |
2. Represent numeric values (sequential) |
![]() |
3. Represent numeric values (diverging) |
![]() |
4. Highlight |
![]() |
The temps_months
dataset:
temps_months <- read_csv("https://wilkelab.org/SDS375/datasets/tempnormals.csv") %>% group_by(location, month_name) %>% summarize(mean = mean(temperature)) %>% mutate( month = factor( month_name, levels = c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec") ), location = factor( location, levels = c("Death Valley", "Houston", "San Diego", "Chicago") ) ) %>% select(-month_name)
The popgrowth
dataset:
US_census <- read_csv("https://wilkelab.org/SDS375/datasets/US_census.csv")US_regions <- read_csv("https://wilkelab.org/SDS375/datasets/US_regions.csv")popgrowth <- left_join(US_census, US_regions) %>% group_by(region, division, state) %>% summarize( pop2000 = sum(pop2000, na.rm = TRUE), pop2010 = sum(pop2010, na.rm = TRUE), popgrowth = (pop2010-pop2000)/pop2000, .groups = "drop" ) %>% mutate(region = factor(region, levels = c("West", "South", "Midwest", "Northeast")))
Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_hue() |
color |
discrete | qualitative |
Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_hue() |
color |
discrete | qualitative |
scale_fill_hue() |
fill |
discrete | qualitative |
Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_hue() |
color |
discrete | qualitative |
scale_fill_hue() |
fill |
discrete | qualitative |
scale_color_gradient() |
color |
continuous | sequential |
Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_hue() |
color |
discrete | qualitative |
scale_fill_hue() |
fill |
discrete | qualitative |
scale_color_gradient() |
color |
continuous | sequential |
scale_color_gradient2() |
color |
continuous | diverging |
Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_hue() |
color |
discrete | qualitative |
scale_fill_hue() |
fill |
discrete | qualitative |
scale_color_gradient() |
color |
continuous | sequential |
scale_color_gradient2() |
color |
continuous | diverging |
scale_fill_viridis_c() |
color |
continuous | sequential |
scale_fill_viridis_d() |
fill |
discrete | sequential |
scale_color_brewer() |
color |
discrete | qualitative, diverging, sequential |
scale_fill_brewer() |
fill |
discrete | qualitative, diverging, sequential |
scale_color_distiller() |
color |
continuous | qualitative, diverging, sequential |
... and there are many many more
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() # no fill scale defined, default is scale_fill_gradient()
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_gradient()
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_viridis_c()
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_viridis_c(option = "B", begin = 0.15)
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_distiller(palette = "YlGnBu")
Scale name: scale_<aesthetic>_<datatype>_<colorscale>()
Scale name: scale_<aesthetic>_<datatype>_<colorscale>()
<aesthetic>
: name of the aesthetic (fill
, color
, colour
)<datatype>
: type of variable plotted (discrete
, continuous
, binned
)<colorscale>
: type of the color scale (qualitative
, sequential
, diverging
, divergingx
)Scale name: scale_<aesthetic>_<datatype>_<colorscale>()
<aesthetic>
: name of the aesthetic (fill
, color
, colour
)<datatype>
: type of variable plotted (discrete
, continuous
, binned
)<colorscale>
: type of the color scale (qualitative
, sequential
, diverging
, divergingx
)Scale function | Aesthetic | Data type | Palette type |
---|---|---|---|
scale_color_discrete_qualitative() |
color |
discrete | qualitative |
scale_fill_continuous_sequential() |
fill |
continuous | sequential |
scale_colour_continous_divergingx() |
colour |
continuous | diverging |
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_continuous_sequential(palette = "YlGnBu", rev = FALSE)
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_continuous_sequential(palette = "Viridis", rev = FALSE)
ggplot(temps_months, aes(x = month, y = location, fill = mean)) + geom_tile(width = 0.95, height = 0.95) + coord_fixed(expand = FALSE) + theme_classic() + scale_fill_continuous_sequential(palette = "Inferno", begin = 0.15, rev = FALSE)
colorspace::hcl_palettes(type = "sequential", plot = TRUE) # all sequential palettes
colorspace::hcl_palettes(type = "diverging", plot = TRUE, n = 9) # all diverging palettes
colorspace::divergingx_palettes(plot = TRUE, n = 9) # all divergingx palettes
ggplot(popgrowth, aes(x = pop2000, y = popgrowth, color = region)) + geom_point() + scale_x_log10() # no color scale defined, default is scale_color_hue()
ggplot(popgrowth, aes(x = pop2000, y = popgrowth, color = region)) + geom_point() + scale_x_log10() + scale_color_hue()
library(ggthemes) # for scale_color_colorblind()ggplot(popgrowth, aes(x = pop2000, y = popgrowth, color = region)) + geom_point() + scale_x_log10() + scale_color_colorblind() # uses Okabe-Ito colors
ggplot(popgrowth, aes(x = pop2000, y = popgrowth, color = region)) + geom_point() + scale_x_log10() + scale_color_manual( values = c(West = "#E69F00", South = "#56B4E9", Midwest = "#009E73", Northeast = "#F0E442") )
Name | Hex code | R, G, B (0-255) |
---|---|---|
orange | #E69F00 | 230, 159, 0 |
sky blue | #56B4E9 | 86, 180, 233 |
bluish green | #009E73 | 0, 158, 115 |
yellow | #F0E442 | 240, 228, 66 |
blue | #0072B2 | 0, 114, 178 |
vermilion | #D55E00 | 213, 94, 0 |
reddish purple | #CC79A7 | 204, 121, 167 |
black | #000000 | 0, 0, 0 |
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |