title: ggplot2 warning: Stacking not well defined when ymin != 0
body: <p>Perhaps the answer is to just be warned.  I am attmepting to use a scaled and centered variable to look at how observations differ from the mean value.  This plot is a common practice.  But when I do this I get a warning from <code>ggplot2</code>.  </p>
  
  <pre><code>Warning messages:
  1: Stacking not well defined when ymin != 0 
  </code></pre>
  
  <p>I like to have ggplot2 and the rest of the world happy and no warnings coming my way.  I tried to get rid of the warning in the following ways and searched SO (see links at bottom for some more promising questions) for related questions.  Still my friend ggplot2 is warning me.</p>
  
  <p><strong>QUESTION(S):</strong>     </p>
  
  <ol>
  <li>How can I make the warning go away?       </li>
  <li>Can I ignore the warning? </li>
  <li>Is there something wrong with this practice?</li>
  </ol>
  
  <p><strong>Code attempts:</strong></p>
  
  <pre><code>## The data
  mtcars$scaled_mpg &lt;- unlist(tapply(mtcars$mpg, mtcars$cyl, scale))
  mtcars &lt;- mtcars[order(mtcars$cyl), ]
  mtcars$ID &lt;- unlist(tapply(mtcars$cyl, mtcars$cyl, seq_along))
  mtcars$ID &lt;- factor(sprintf("%02d", mtcars$ID ))
  
  ##  ================ Attempt 1 ================   
  ggplot(mtcars, aes(x = ID, y = scaled_mpg, fill = factor(cyl))) +
      geom_bar(stat="identity") + facet_grid(cyl~.)
  
  ##  ================ Attempt 2 ================     
  ggplot(mtcars, aes(x = ID, fill = factor(cyl))) +
      geom_bar(aes(weight = scaled_mpg)) + facet_grid(cyl~.)
  
  ##  ================ Attempt 3 ================  
  dat1 &lt;- subset(mtcars, scaled_mpg &gt;= 0)
  dat2 &lt;- subset(mtcars, scaled_mpg &lt; 0)
  
  ggplot() +
      geom_bar(data = dat1, aes(x = ID, y = scaled_mpg, 
          fill = factor(cyl)),stat = "identity") +
      geom_bar(data = dat2, aes(x = ID, y = scaled_mpg, 
          fill= factor(cyl)),stat = "identity") + 
      facet_grid(cyl~.)
  </code></pre>
  
  <p><strong>The plot:</strong></p>
  
  <p><img src="https://i.stack.imgur.com/PttXk.png" alt="enter image description here"></p>
  
  <p><strong>Similar posts:</strong>    </p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/15392570/set-length-of-geom-hline-in-geom-bar-plot">set length of `geom_hline` in `geom_bar` plot</a></li>
  <li><a href="https://stackoverflow.com/questions/18137951/ggplot2-stacking-not-well-defined-when-ymin-0">ggplot2 - stacking not well defined when ymin !=0</a></li>
  <li><a href="https://stackoverflow.com/questions/13734368/ggplot2-and-a-stacked-bar-chart-with-negative-values">ggplot2 and a Stacked Bar Chart with Negative Values</a></li>
  </ul>