title: ggplot2: how to combine layers of geom_line and geom_point with error bars
body: <p>I'm trying to generate a line graph of four data conditions, plotting the average of each condition as a function of time. The conditions vary in a 2x2 design, so I've been using geom_line (blue/red lines that are solid/dashed) and geom_point (blue/red shapes that are squares/circles) to plot the data. That works just fine when I use layers, but I'd also like to include error bars at each time point:</p>
  
  <pre><code>pd &lt;- position_dodge(.1)
  ggplot(data = df) +
    geom_line(data=subset(df, condition == "A"), aes(E, avg),
          colour="red", size=1) +
    geom_point(data=subset(df, condition == "A"), aes(E, avg), 
           colour="red", shape=24, fill="white", size=5) +
    geom_line(data=subset(df, condition == "B"), aes(E, avg),
          colour="red", linetype="dashed",size=1) +
    geom_point(data=subset(df, condition == "B"), aes(E, avg), 
           colour="red", shape=24, fill="red", size=5) +
    geom_line(data=subset(df, condition == "C"), aes(E, avg),
          colour="blue", size=1) +
    geom_point(data=subset(df, condition == "C"), aes(E, avg), 
           colour="blue", shape=21, fill="white", size=5) +
    geom_line(data=subset(df, condition == "D"), aes(E, avg),
          colour="blue", linetype="dashed",size=1) +
    geom_point(data=subset(df, condition == "D"), aes(E, avg), 
           colour="blue", shape=21, fill="blue", size=5)
  </code></pre>
  
  <p>The above code works fine. But if I then add in this line:</p>
  
  <pre><code>+ geom_errorbar(aes(x=E, ymin=avg-se, ymax=avg+se), width=.1, position=pd)
  </code></pre>
  
  <p>The plot does not take pd (which has been defined previously) into account, and the bars are hard to distinguish from one another (i.e., overlapping). How do I remedy this?</p>