title: How can I make consistent-width plots in ggplot (with legends)?
body: <p>I've got a few different categories that I want to plot.  These are <em>different</em> categories, each with their own set of labels, but which makes sense to group together in the document.  The following gives some simple stacked bar chart examples:</p>
  
  <pre><code>df &lt;- data.frame(x=c("a", "b", "c"),
                   y=c("happy", "sad", "ambivalent about life"))
  ggplot(df, aes(x=factor(0), fill=x)) + geom_bar()
  ggplot(df, aes(x=factor(0), fill=y)) + geom_bar()
  </code></pre>
  
  <p>The problem is that with different labels, the legends have different widths, which means the plots have different widths, leading to things looking a bit goofy if I make a table or <code>\subfigure</code> elements.  How can I fix this?</p>
  
  <p>Is there a way to explicitly set the width (absolute or relative) of either the plot or the legend?</p>
  
  <p><a href="https://i.stack.imgur.com/8gmWT.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8gmWT.png" alt="Chart 1 based on x (wider)"></a>
  <a href="https://i.stack.imgur.com/MrkI4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/MrkI4.png" alt="Chart 2 based on y (narrower)"></a></p>