Are you just trying to get end caps on the whiskers? If so, see the code below, which is a modification of kjhealy's answer. Note that:
- The
stat_boxplot
andgeom_boxplot
calls are dodged by the same amount, so that they will align properly. - The
width
argument ingeom_boxplot
is set to the same value as the dodging width, so that the dodged boxplots will abut each other. Change to a smaller value if you'd like a little space between the boxplots within each pair. - The
width
argument tostat_boxplot
sets the width of the whisker end caps.
pd = position_dodge(width = 0.5)
ggplot(airquality_trimmed, aes(x = Month, y = Ozone, fill = Temp.f)) +
stat_boxplot(geom="errorbar", position=pd, width=0.2) +
geom_boxplot(width=0.5, position=pd)