I have a similar question previously discussed for barplots, but with missing solution for boxplots: Consistent width for geom_bar in the e
We can make use of the preserve
argument in position_dodge
.
From ?position_dodge
preserve: Should dodging preserve the total width of all elements at a position, or the width of a single element?
ggplot(data.sub, aes(x=variety, y=note, fill=treatment)) +
geom_boxplot(position = position_dodge(preserve = "single"))