在轉換後的刻度上加入統計
在上一個練習中,我們看到了 coord_trans() 函式的實用性,不過要小心!記住,統計量是基於未轉換的資料計算的。經過座標軸轉換後,線性模型看起來可能就沒那麼「線性」了。我們再回顧上一個練習的兩張圖,來比較它們的線性模型。
本練習屬於課程
ggplot2 中級資料視覺化
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Plot with a scale_*_*() function:
ggplot(msleep, aes(bodywt, brainwt)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE) +
# Add a log10 x scale
___ +
# Add a log10 y scale
___ +
ggtitle("Scale functions")