title: ggplot2 - ordered factor stacking in inverted order in barplot with positive and negative y-values
body: <p>I am trying to build a stacked barplot and I am having trouble with the order of the stacks.</p>
  <p>I've got the variables name, value, count, and Percent.  value is 1-7. Any percent assigned to 5, 6, or 7 is negative, and I suspect this is where the problem is but I can't figure it out.  When I plot this the order of value in the stack is 5, 6, 7, 4, 3, 2, 1.  It should be 7, 6, 5, 4, 3, 2, 1.  I even tried giving 5, 6, and 7 negative values but that didn't work.</p>
  <p>This is a bare bones version.  The one I hope to produce is &quot;fancy&quot;.  But I am stuck on this one thing.  I am always tripping up in ggplot2, even though I like it lot.</p>
  <pre><code>df &lt;- structure(list(name = c(&quot;cloud_data_available&quot;, &quot;cloud_data_available&quot;, 
  &quot;cloud_data_available&quot;, &quot;cloud_data_available&quot;, &quot;cloud_data_available&quot;, 
  &quot;cloud_data_available&quot;, &quot;cloud_data_available&quot;, &quot;on_premise_data_available&quot;, 
  &quot;on_premise_data_available&quot;, &quot;on_premise_data_available&quot;, &quot;on_premise_data_available&quot;, 
  &quot;on_premise_data_available&quot;, &quot;on_premise_data_available&quot;, &quot;on_premise_data_available&quot;
  ), value = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 1L, 2L, 3L, 
  4L, 5L, 6L, 7L), .Label = c(&quot;1&quot;, &quot;2&quot;, &quot;3&quot;, &quot;4&quot;, &quot;5&quot;, &quot;6&quot;, &quot;7&quot;
  ), class = c(&quot;ordered&quot;, &quot;factor&quot;)), count = c(1L, 2L, 1L, 5L, 
  18L, 52L, 55L, 2L, 4L, 5L, 4L, 16L, 33L, 70L), Percent = c(0.7, 
  1.5, 0.7, 3.7, -13.4, -38.8, -41, 1.5, 3, 3.7, 3, -11.9, -24.6, 
  -52.2)), row.names = c(NA, -14L), groups = structure(list(name = c(&quot;cloud_data_available&quot;, 
  &quot;on_premise_data_available&quot;), .rows = structure(list(1:7, 8:14), ptype = integer(0), class = c(&quot;vctrs_list_of&quot;, 
  &quot;vctrs_vctr&quot;, &quot;list&quot;))), row.names = 1:2, class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;), .drop = TRUE), class = &quot;data.frame&quot;)
  
  ggplot(df, aes(x=name, y = Percent, fill=value, label=value))+                          
    #geom_bar(stat=&quot;, width = .5, position = position_stack(reverse = TRUE)) +
    geom_col(position = &quot;stack&quot;, width = .5) +
    scale_x_discrete() +
    geom_text(size = 3, position = position_stack(vjust = 0.5)) +
    coord_flip()
  </code></pre>
  <p>This is what I get:</p>
  <p><a href="https://i.stack.imgur.com/tPBbN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPBbN.png" alt="enter image description here" /></a></p>
  <p>Thanks, in advance!  I always learn something new when I come here.</p>