title: How to make variable bar widths in ggplot2 not overlap or gap
body: <p>geom_bar seems to work best when it has fixed width bars - even the spaces between bars seem to be determined by width, according to the <a href="http://docs.ggplot2.org/current/geom_bar.html" rel="noreferrer">documentation</a>. When you have variable widths, however, it does not respond as I would expect, leading to overlaps or gaps between the different bars (as shown <a href="https://stackoverflow.com/questions/11345943/bar-graph-in-ggplot2-with-width-as-a-variable-and-even-spacing-between-bars">here</a>).</p>
  
  <p>To see what I mean, please try this very simple reproducible example:</p>
  
  <pre><code>x &lt;- c("a","b","c")
  w &lt;- c(1.2, 1.3, 4) # variable widths
  y &lt;- c(9, 10, 6) # variable heights
  
  ggplot() + 
  geom_bar(aes(x = x, y = y, width = w, fill=x), 
   stat="identity", position= "stack")
  </code></pre>
  
  <p>What I really want is for the different bars to be just touching, but not overlapping, like in a histogram.</p>
  
  <p>I've tried adding <code>position= "stack"</code>, <code>"dodge"</code>, and <code>"fill</code>, but none work. Does the solution lie in <code>geom_histogram</code> or am I just not using <code>geom_bar</code> correctly? </p>
  
  <p><img src="https://i.stack.imgur.com/pXqSz.png" alt="geom-plot overlap"></p>
  
  <p>P.s. to see the issue with gaps, try replacing <code>4</code> with <code>0.5</code> in the above code and see the outcome.</p>