設定主題
在多個圖表之間重複使用同一個主題,有助於維持一致的風格。你有幾種方式可以做到:
- 把主題指定給一個變數,然後加到每個圖表上。
- 使用
theme_set()將主題設為預設主題。
一個不錯的做法(本題會用到)是先從內建主題開始,再進一步修改。
plt_prop_unemployed_over_time 已可使用。你先前做的主題已顯示在範例程式碼中。
本練習屬於課程
ggplot2 資料視覺化入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Save the theme as theme_recession
___ <- theme(
rect = element_rect(fill = "grey92"),
legend.key = element_rect(color = NA),
axis.ticks = element_blank(),
panel.grid = element_blank(),
panel.grid.major.y = element_line(color = "white", size = 0.5, linetype = "dotted"),
axis.text = element_text(color = "grey25"),
plot.title = element_text(face = "italic", size = 16),
legend.position = c(0.6, 0.1)
)
# Combine the Tufte theme with theme_recession
theme_tufte_recession <- ___
# Add the Tufte recession theme to the plot
___