Bar plots: position dodging
In the previous exercise we used the mtcars
dataset to draw a dynamite plot about the weight of the cars per cylinder type.
In this exercise we will add a distinction between transmission type, fam
, for the dynamite plots and explore position dodging (where bars are side-by-side).
Cet exercice fait partie du cours
Intermediate Data Visualization with ggplot2
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# 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)