調整標籤
我們的初始圖已經把資料畫出來了,但在看起來像 FiveThirtyEight 的圖之前,還有不少調整要做。先從圖上方與周圍的文字開始吧。我們已經看到 ggplot2 的 labs() 圖層可以接受多個引數來修改文字。你在前一個練習建立的圖 initial_plot 已為你載入。
本練習屬於課程
Tidyverse 的類別資料
練習說明
- 為了與 FiveThirtyEight 的圖一致:
- 加上標題、副標題與註記
- 將 x 與 y 軸的標籤設為空字串
- 將結果存成新圖
titled_plot。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
titled_plot <- initial_plot +
# Add the title, subtitle, and caption
___(___ = "Hell Is Other People In A Pressurized Metal Tube",
___ = "Percentage of 874 air-passenger respondents who said action is very or somewhat rude",
___ = "Source: SurveyMonkey Audience",
# Remove the x- and y-axis labels
__ = "",
__ = "")
titled_plot