title: Out of order text labels on stack bar plot (ggplot)
body: <p>I'm trying to make a stacked bar chart with text labels, this some example data / code:</p>
  
  <pre><code>library(reshape2)
  
  ConstitutiveHet &lt;- c(7,13)
  Enhancer &lt;- c(12,6)
  FacultativeHet &lt;- c(25,39)
  LowConfidence &lt;- c(3,4)
  Promoter &lt;- c(5,4)
  Quiescent &lt;- c(69,59)
  RegPermissive &lt;- c(23,18)
  Transcribed &lt;- c(12,11)
  Bivalent &lt;- c(6,22)
  group &lt;- c("all","GWS")
  
  meanComb &lt;- data.frame(ConstitutiveHet,Enhancer,LowConfidence,Promoter,Quiescent,RegPermissive,Transcribed,Bivalent,group)
  meanCombM &lt;- melt(meanComb,id.vars = "group")
  
  ggplot(meanCombM,aes(group,value,label=value)) +
       geom_col(aes(fill=variable))+
       geom_text(position = "stack")+
       coord_flip()
  </code></pre>
  
  <p>The text labels appear out of order, they seem to be the mirror image of their intended order. (you get the same problem with or without the <code>coord_flip()</code>)</p>
  
  <p>A poster had a similar problem here:
  <a href="https://stackoverflow.com/questions/44334535/ggplot2-add-ordered-category-labels-to-stacked-bar-chart">ggplot2: add ordered category labels to stacked bar chart</a></p>
  
  <p>An answer to their post propsed reversing the order of the values in the groups, which I tried (see below), the resulting order on the plot is not one i've been able to figure out. Also this approach seems hacky, is there a bug here or am I missing something?</p>
  
  <pre><code>x &lt;- c(rev(meanCombM[meanCombM$group=="GWS",]$value),rev(meanCombM[meanCombM$group=="all",]$value))
  
  ggplot(meanCombM,aes(group,value,label=x)) +
  geom_col(aes(fill=variable))+
  geom_text(position = "stack")+
  coord_flip()
  </code></pre>