title: reduce space between grid.arrange plots
body: <p>I asked a question <a href="https://stackoverflow.com/questions/13294952/left-align-two-graph-edges-ggplot">HERE</a> about grid arrange and got a terrific response.  I want to reduce the space between plots now but get an error.  First I present the code that works and then the error code (what I tried).  I can't actually find <code>grid.arrange</code> and have always assumed it comes from <code>gridExtra</code> but I may be incorrect.</p>
  
  <p>so 2 parts:</p>
  
  <ol>
  <li>How can I reduce space between plots with grid arrange</li>
  <li>Where can I find documentation about <code>grid.arrange</code> (Baptiste I know you maintain gridExtra so please correct my thinking or use of the package if I'm not using it in the way it was intended.)</li>
  </ol>
  
  <p><strong>Good code bad space</strong></p>
  
  <pre><code>require(ggplot2);require(gridExtra)
  A &lt;- ggplot(CO2, aes(x=Plant)) + geom_bar() +
      coord_flip() + ylab("")
  B &lt;- ggplot(CO2, aes(x=Type)) + geom_bar() +coord_flip() 
  
  
   gA &lt;- ggplot_gtable(ggplot_build(A))
   gB &lt;- ggplot_gtable(ggplot_build(B))
   maxWidth = grid::unit.pmax(gA$widths[2:3], gB$widths[2:3])
   gA$widths[2:3] &lt;- as.list(maxWidth)
   gB$widths[2:3] &lt;- as.list(maxWidth)
   grid.arrange(gA, gB, ncol=1)
  </code></pre>
  
  <p><strong>Bad code (my try)</strong></p>
  
  <pre><code>require(ggplot2);require(gridExtra)
  A &lt;- ggplot(CO2, aes(x=Plant)) + geom_bar() +
      coord_flip() + ylab("") + theme(plot.margin= unit(1, "cm"))
  B &lt;- ggplot(CO2, aes(x=Type)) + geom_bar() +coord_flip() 
  
  
   gA &lt;- ggplot_gtable(ggplot_build(A))
   gB &lt;- ggplot_gtable(ggplot_build(B))
   maxWidth = grid::unit.pmax(gA$widths[2:3], gB$widths[2:3])
   gA$widths[2:3] &lt;- as.list(maxWidth)
   gB$widths[2:3] &lt;- as.list(maxWidth)
   grid.arrange(gA, gB, ncol=1)
  </code></pre>
  
  <p><strong>The error:</strong></p>
  
  <pre><code>Error in `[.unit`(theme$plot.margin, 2) : 
    Index out of bounds (unit subsetting)
  </code></pre>