開始使用免費開始

調整視窗避免標籤與圖框重疊

使用上一支影片介紹的函式來改變繪圖區的視窗範圍。同時套用你的自訂主題。

本練習屬於課程

在 Tidyverse 中以資料溝通

檢視課程

練習說明

  • 透過重設笛卡兒座標系統的 x 範圍為 2541,來修正標籤重疊的問題。請務必使用不會裁切圖形幾何元素的函式。
  • 記得你的自訂 theme_ilo() 函式嗎?把它套用到這張圖上。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Reuse ilo_dot_plot
ilo_dot_plot <- ilo_dot_plot +
  # Add labels to the plot
  labs(
    x = "Working hours per week",
    y = "Country",
    title = "People work less in 2006 compared to 1996",
    subtitle = "Working hours in European countries, development since 1996",
    caption = "Data source: ILO, 2017"
  ) +
  # Apply your theme
  ___ +
  # Change the viewport
  ___(___ = c(___, ___))
  
# View the plot
ilo_dot_plot
編輯並執行程式碼