title: ggplot2 position_dodge affects error bar width
body: <p>I am trying to make a line and point graph with errorbars. It has different factors, however some factors have only one value. I found out that if i use position_dodge, one of the single value factor has a much wider error bar compared to the other error bars in the graphs. Somehow position_dodge has an influence on the width on the error bar. I did not found anyone that had the same problem before so I hope that someone can help me. </p>
  
  <p>The dummy data: </p>
  
  <pre><code>require(ggplot2)
  
  x &lt;- c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,3,3,5)
  y &lt;- c(3,5,6,3,5,3,5,6,2,6,3,7,3,6,2,1,5,8,7)
  se &lt;- x*0.2
  treatment &lt;- c("A", "B","C", "D","A", "B","C", "D","A", "B","C", "D","A",    "B","C", "D","E", "F", "G" )
  data &lt;- data.frame(x, y, se ,treatment)
  data$treatment &lt;- as.factor(data$treatment)
  </code></pre>
  
  <p>First a plot without position_dodge - everything is fine</p>
  
  <pre><code># Without position dodge
  myplot &lt;- ggplot(data, aes(x=x, y=y, group= treatment,  fill = treatment, colour = treatment)) +
    geom_line(stat="identity", size = 1) +
    geom_point(stat="identity", size = 3, shape = 21) + 
    geom_errorbar(aes(ymin = y-se, ymax = y+se), width = 0.2)
  
  myplot
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/HHaKq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HHaKq.png" alt="plot without position_dodge"></a></p>
  
  <p>Now a plot with position dodge: </p>
  
  <pre><code># With position dodge
  myplot &lt;- ggplot(data, aes(x=x, y=y, group= treatment,  fill = treatment, colour = treatment)) +
    geom_line(stat="identity", size = 1, position=position_dodge(width=0.2)) +
    geom_point(stat="identity", size = 3, shape = 21, position=position_dodge(width=0.2)) + 
    geom_errorbar(aes(ymin = y-se, ymax = y+se), width = 0.2, position=position_dodge(width=0.2))
  
  myplot
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/lyT9E.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lyT9E.png" alt="Plot with position_dodge"></a></p>
  
  <p>As you can see the error bar on the far right has a much larger width compared to the other error bars. This is probably because there are no overlapping x variables for this point, and than the error bars can have a normal size. I still would like to know how I can get the error bars to have the same width. </p>