Visualization Best Practices in R
Nick Strayer
Instructor
who_disease %>%
filter(region == 'EMR', disease == 'measles', year == 2015) %>%
ggplot(aes(x = country, y = cases)) +
geom_col()

geom_bar() and geom_col() don't allow categories on y-axisbusy_bars <- who_disease %>%
filter(region == 'EMR', disease == 'measles', year == 2015) %>%
ggplot(aes(x = country, y = cases)) +
geom_col()
busy_bars + coord_flip() # swap x and y axes!



plot <- who_disease %>%
filter(country == "India", year == 1980) %>%
ggplot(aes(x = disease, y = cases)) +
geom_col()
# Remove vertical grid lines
plot + theme(
panel.grid.major.x = element_blank()
)

theme_minimal() is a quick fixwho_subset %>%
ggplot(aes(y = reorder(country, cases_2016), x = log10(cases_2016))) +
# Point size increased
geom_point(size = 2) +
# Theme minimal for light background
theme_minimal()

Visualization Best Practices in R