title: How to control ordering of stacked bar chart using identity on ggplot2
body: <p>Using this dummy <code>data.frame</code></p>
  
  <pre><code>ts &lt;- data.frame(x=1:3, y=c("blue", "white", "white"), z=c("one", "one", "two"))
  </code></pre>
  
  <p>I try and plot with category "blue" on top.</p>
  
  <pre><code>ggplot(ts, aes(z, x, fill=factor(y, levels=c("blue","white" )))) + geom_bar(stat = "identity")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/CnWfE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/CnWfE.png" alt="enter image description here"></a></p>
  
  <p>gives me "white" on top. and</p>
  
  <pre><code>ggplot(ts, aes(z, x, fill=factor(y, levels=c("white", "blue")))) + geom_bar(stat = "identity")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/qtnym.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qtnym.png" alt="enter image description here"></a></p>
  
  <p>reverses the colors, but still gives me "white" on top. How can I get "blue" on top?</p>