Pie charts are BAD‼️
image credit: Claus O. Wilke
image credit: Claus O. Wilke
image credit: Claus O. Wilke
image credit: Claus O. Wilke
HCL: perceptually-based and device-independent
3 fundamental use cases for colours in data visualisations:
3 types of colour palettes ColorBrewer
colorspace::hcl_palettes("Qualitative", plot = TRUE, n = 7)
colorspace::hcl_palettes("Sequential", plot = TRUE, n = 7)
colorspace::hcl_palettes("Diverging", plot = TRUE, n = 7)
time_use %>% ggplot(aes(country, time_minutes)) + geom_col( aes(fill = category), position = "dodge") + scale_fill_brewer(palette = "Dark2") + labs(y = "") + theme(legend.position = "bottom")
time_use %>% ggplot(aes(country, time_minutes)) + geom_col( aes(fill = category), position = "dodge") + scale_fill_manual( values = c("#EF476F", "#FFD166", "#06D6A0", "#118AB2", "#073B4C", "grey")) + labs(y = "") + theme(legend.position = "bottom")
ℹ️ Approximately 8% of males and 0.5% of females suffer from some sort of color-vision deficiency.
reference: Claus O. Wilke Fundamentals of Data Visualization
colorspace::hclwizard()
colorspace::hcl_color_picker()
breaks
, labels
, and limits
.scale_[aes]_[datatype]()
scale | Description |
---|---|
scale_alpha, scale_alpha_continuous, scale_alpha_binned, scale_alpha_discrete | Alpha transparency scales |
scale_x_binned, scale_y_binned | Positional scales for binning continuous data (x & y) |
scale_colour_brewer, scale_fill_brewer, scale_colour_distiller, scale_fill_distiller | Sequential, diverging and qualitative colour scales from colorbrewer.org |
scale_colour_continuous, scale_fill_continuous, scale_colour_binned, scale_fill_binned | Continuous and binned colour scales |
scale_colour_discrete, scale_fill_discrete | Discrete colour scales |
covid19 <- read_csv("data/covid19-daily-cases.csv")covid19
#> # A tibble: 15,677 x 3#> country_region date confirmed#> <chr> <date> <dbl>#> 1 Afghanistan 2020-03-01 1#> 2 Afghanistan 2020-03-02 1#> 3 Afghanistan 2020-03-03 2#> 4 Afghanistan 2020-03-04 4#> 5 Afghanistan 2020-03-05 4#> 6 Afghanistan 2020-03-06 4#> # … with 15,671 more rows
full screen of legends
perceive the rate of infections, slowing down
covid19 %>% ggplot(aes( x = date, y = confirmed, colour = country_region)) + geom_line() + guides(colour = FALSE) + scale_y_log10()
Rob J Hyndman's blog post on Why log ratios are useful for tracking COVID-19
covid19_rel <- covid19 %>% group_by(country_region) %>% mutate(days = as.numeric(date - min(date))) %>% ungroup()covid19_rel
#> # A tibble: 15,677 x 4#> country_region date confirmed days#> <chr> <date> <dbl> <dbl>#> 1 Afghanistan 2020-03-01 1 0#> 2 Afghanistan 2020-03-02 1 1#> 3 Afghanistan 2020-03-03 2 2#> 4 Afghanistan 2020-03-04 4 3#> 5 Afghanistan 2020-03-05 4 4#> 6 Afghanistan 2020-03-06 4 5#> # … with 15,671 more rows
log(0) -> Inf
covid19_nz <- covid19_rel %>% filter(country_region == "New Zealand")p_nz <- covid19_rel %>% ggplot(aes(x = days, y = confirmed, group = country_region)) + geom_line(colour = "grey", alpha = 0.5) + geom_line(colour = "#238b45", size = 1, data = covid19_nz) + scale_y_log10() + guides(colour = FALSE)p_nz
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 |