開始使用免費開始

長條圖:並排位置(position dodging)

在前一個練習中,我們使用 mtcars 資料集,依汽缸數繪製汽車重量的「炸藥圖」(dynamite plot)。

在這個練習中,我們要在炸藥圖中加入變速箱型態 fam 的區分,並探索 position dodging(也就是讓長條並排顯示)。

本練習屬於課程

ggplot2 中級資料視覺化

檢視課程

動手互動練習

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

# Update the aesthetics to color and fill by fam
ggplot(mtcars, aes(x = fcyl, y = wt)) +
  stat_summary(fun = mean, geom = "bar") +
  stat_summary(fun.data = mean_sdl, fun.args = list(mult = 1), geom = "errorbar", width = 0.1)
編輯並執行程式碼