hadley/ggplot2 — Issue #431: geom_errorbar does not work properly with position_dodge in 0.9.0
Author: michaelhallquist
Created: 2012-03-08 15:50:17+00:00
State: open

A plot I previously created in ggplot2-0.8.9 no longer dodges the error bars despite properly dodging geom_line and geom_point. Here's the command I used. I'm running R 2.14.1 on Mac OS X 10.7. Downgrading to 0.8.9 fixed this problem. The result is a plot where the points and lines are dodged, but the error bars are are overlaid.

limits <- aes(ymax=mean + std.error, ymin=mean - std.error, linetype=NULL)
base_size=11

pos <- position_dodge(width=0.2)

Totalplot <- ggplot(allTotal, aes(x=time, y=mean, linetype=group)) + theme_bw(base_size=base_size) +
geom_line(position=pos, size=1.1) +
geom_errorbar(limits, width=0.2, position=pos) +
geom_point(position=pos, size=2.5) +
facet_wrap(~Disorder) +
ylab(paste("Mean number of total PD symptoms")) + xlab("Time since enrollment (years)") +
opts(legend.key.size=unit(2, "lines"), axis.ticks.margin = unit(0.25, "lines"), plot.margin = unit(c(1, 1, 0.5, 0.5), "lines")) +
opts(panel.margin = unit(0.7, "lines")) +
scale_x_continuous(breaks=c(0,1,2,3)) +
scale_linetype("Latent\ntrajectory") +
opts(axis.title.x = theme_text(size = base_size, vjust = 0.0)) +
opts(axis.title.y = theme_text(size = base_size, hjust = 0.5, vjust=0.3, angle=90)) +
opts(legend.title = theme_text(size = base_size * 0.8, hjust = 0))