title: Flip ordering of legend without altering ordering in plot
body: <p>I have found that when adding <code>coord_flip()</code> to certain plots using ggplot2 that the order of values in the legend no longer lines up with the order of values in the plot.</p>
  
  <p>For example:</p>
  
  <pre><code>dTbl = data.frame(x=c(1,2,3,4,5,6,7,8),
                    y=c('a','a','b','b','a','a','b','b'),
                    z=c('q','q','q','q','r','r','r','r'))
  
  print(ggplot(dTbl, aes(x=factor(y),y=x, fill=z)) +
        geom_bar(position=position_dodge(), stat='identity') +
        coord_flip() +
        theme(legend.position='top', legend.direction='vertical'))
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bNwCU.png" alt="enter image description here"></p>
  
  <p>I would like the 'q' and 'r' in the legend to be reversed without changing the order of 'q' and 'r' in the plot.</p>
  
  <p><code>scale.x.reverse()</code> looked promising, but it doesn't seem to work within factors (as is the case for this bar plot).</p>