將圖儲存為變數
圖可以先儲存為變數,之後再用 + 運算子繼續加入圖層。當你想從同一個基礎圖產生多個相關圖時,這非常實用。
本練習屬於課程
ggplot2 資料視覺化入門
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Draw a ggplot
plt_price_vs_carat <- ___(
# Use the diamonds dataset
___,
# For the aesthetics, map x to carat and y to price
___(___, ___)
)
# Add a point layer to plt_price_vs_carat
___ + ___