title: How do I reverse the order in which error bars appear using geom_errorbar() in R?
body: <p>I have the following example plot:</p>
  
  <pre><code>test &lt;- data.frame("Factor" = as.factor(c("O", "C", "A")), 
                         b = c(0.18, .34, .65, -.13, .38, .26), 
                         lower95 = c(-.1, .09, .34, -.52, .10, -.02), 
                         upper95 = c(.48, .58, .98, .26, .67, .56), 
                         group = factor(c("Experiment 1","Experiment 2")))
  
  test$Factor &lt;- factor(test$Factor, as.character(test$Factor))
  test$group &lt;- factor(test$group, as.character(test$group))
  
  ggplot(test, aes(Factor, b, colour = group)) +
    geom_errorbar(aes(ymin = lower95, ymax = upper95), 
              size = 1,
              width = .5, 
              position = 'dodge') +
    geom_hline(yintercept = 0) +
    ylim(-1.25, 1.25) +
    coord_flip() +
    theme_bw() + 
    ggtitle("Title") +
    theme(
  axis.text=element_text(size = 20), 
  axis.title=element_text(size = 18),
  plot.title = element_text(size = 20, face = "bold"),
  axis.text.y=element_text(size = 12)
    )
  </code></pre>
  
  <p>As you'll see, the error bars appear in the reverse order (from top to bottom) as they do in the legend. I would like Experiment 1 error bars to appear above Experiment 2 error bars.</p>
  
  <p>I have tried</p>
  
  <pre><code>ggplot(test, aes(Factor, b, colour = forcats::fct_rev(groups)
  </code></pre>
  
  <p>But this reverses the order of the <em>group labels</em> in the legend, not the order of the colours in the legend–which is what would work. I have also tried reversing the order in which I enter them in the data frame and this does not solve the problem.</p>
  
  <p>I would appreciate some help!</p>