title: Overlay ggplots: error bars of same groupings but different data
body: <p>How can I overlay the following two plots, the first keeping colors defined as-is, and the second one providing reference line/errorbars in black. I don't have access to the raw data.</p>
  
  <p>Edit: The black and colored error bars from the same c segment should have the same abscissa. The abscissa of different <code>c</code> segments should be offset by <code>position_dodge</code>.</p>
  
  <p>I've tried geom_step(), then plot1 + plot2, which is closest to where I'd like to get, but there I loose the second plot's layout.</p>
  
  <pre><code>library(dplyr)
  library(ggplot2)
  
  dta.str &lt;- "G,C,P,y,ci
  A,d,III,166.856088,34.719594
  A,d,I,190.748296,37.181357
  A,d,II,241.645888,47.168545
  A,e,III,121.719736,28.456342
  A,e,I,157.062248,36.273819
  A,e,II,205.818768,48.619195
  A,n,III,23.9916,8.624696
  A,n,I,28.104488,7.401821
  A,n,II,41.369656,10.522883
  B,d,III,171.418816,14.739214
  B,d,I,201.753368,16.673325
  B,d,II,266.013168,21.616907
  B,e,III,145.256352,10.781806
  B,e,I,164.20732,11.317529
  B,e,II,220.398488,15.320057
  B,n,III,28.424464,3.211746
  B,n,I,28.857352,3.106672
  B,n,II,40.594432,4.191482"
  
  dta &lt;- read.csv( text=dta.str )
  
  pd &lt;- position_dodge(0.1) # if 0.1, move them .05 to the left and right
  
  p &lt;- ggplot( dta %&gt;% filter( G == "A") , aes(x = P, y = y , colour = C )) + 
        geom_errorbar(aes(ymin=y-ci, ymax=y+ci), width=.1 , position=pd) +
        geom_line(position=pd,aes(group=C)) +
        geom_point(position=pd)
  
  p &lt;- p + ggplot( data = dta %&gt;% filter( G == "B") , aes(x = P, y = y , colour = C  )) + 
        geom_errorbar(aes(ymin=y-ci, ymax=y+ci), width=.1 , position=pd) +
        geom_line(position=pd,aes(group=C) ) +
        geom_point(position=pd)
  </code></pre>