移動圖例
就用一張能清楚傳達重點、可直接刊登的圖來為本課程收尾吧。
若要調整圖表的外觀樣式,呼叫 theme() 並將對應的屬性設定為新的值。例如,以下程式碼會更改圖例的位置。
p + theme(legend.position = new_value)
這裡的 new_value 可以是:
"top"、"bottom"、"left"、"right'":將圖例放在圖的相應邊。"none":不要顯示圖例。c(x, y):c(0, 0)表示左下角,c(1, 1)表示右上角。
我們回到先前的經濟衰退期間折線圖(指定為 plt_prop_unemployed_over_time)。
本練習屬於課程
ggplot2 資料視覺化入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# View the default plot
plt_prop_unemployed_over_time
# Remove legend entirely
plt_prop_unemployed_over_time +
___