R 視覺化最佳實務
Nick Strayer
Instructor
who_disease %>%
filter(region == 'EMR', disease == 'measles', year == 2015) %>%
ggplot(aes(x = country, y = cases)) +
geom_col()

geom_bar() 與 geom_col() 不允許在 y 軸放類別busy_bars <- who_disease %>%
filter(region == 'EMR', disease == 'measles', year == 2015) %>%
ggplot(aes(x = country, y = cases)) +
geom_col()
busy_bars + coord_flip() # 交換 x 與 y 軸!



plot <- who_disease %>%
filter(country == "India", year == 1980) %>%
ggplot(aes(x = disease, y = cases)) +
geom_col()
# 移除垂直格線
plot + theme(
panel.grid.major.x = element_blank()
)

theme_minimal() 可快速改善who_subset %>%
ggplot(aes(y = reorder(country, cases_2016), x = log10(cases_2016))) +
# 加大點的尺寸
geom_point(size = 2) +
# 淺色背景的 theme_minimal
theme_minimal()

R 視覺化最佳實務