在圖中的線條上加入箭頭
把年份標籤改為在 geom_path() 呼叫中使用 arrow 參數,來顯示變化方向。箭頭會從 1996 指向 2006,因為資料集就是這樣排序的。arrow() 函式有兩個參數:第一個是 length,可以用你在先前練習見過的 unit() 來指定;第二個是 type,用來定義箭頭端點的外觀。
本練習屬於課程
在 Tidyverse 中以資料溝通
練習說明
- 使用
arrow參數與arrow()函式呼叫,為每條線加入箭頭。 - 對箭頭指定
length為1.5"mm"(透過unit()呼叫),以及type為"closed"。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
ggplot(ilo_data) +
geom_path(aes(x = working_hours, y = country),
# Add an arrow to each path
arrow = ___(___ = ___(___, "___"), ___ = "___"))