条形图:并排位置(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)