title: Align multiple ggplot2 plots with grid
body: <h1>Context</h1>
  
  <p>I want to plot two ggplot2 on the same page with the same legend. <a href="http://code.google.com/p/gridextra/wiki/arrangeGrob" rel="noreferrer">http://code.google.com/p/gridextra/wiki/arrangeGrob</a> discribes, how to do this. This already looks good. But... In my example I have two plots with the same x-axis and different y-axis. When the range of the the y-axis is at least 10 times higher than of the other plot (e.g. 10000 instead of 1000), ggplot2 (or grid?) does not align the plots correct (see Output below).</p>
  
  <h1>Question</h1>
  
  <p>How do I also align the left side of the plot, using two different y-axis?</p>
  
  <h1>Example Code</h1>
  
  <pre><code>x = c(1, 2)
  y = c(10, 1000)
  data1 = data.frame(x,y)
  p1 &lt;- ggplot(data1) + aes(x=x, y=y, colour=x) + geom_line()
  
  y = c(10, 10000)
  data2 = data.frame(x,y)
  p2 &lt;- ggplot(data2) + aes(x=x, y=y, colour=x) + geom_line()
  
  
  # Source: http://code.google.com/p/gridextra/wiki/arrangeGrob
  leg &lt;- ggplotGrob(p1 + opts(keep="legend_box"))
  legend=gTree(children=gList(leg), cl="legendGrob")
  widthDetails.legendGrob &lt;- function(x) unit(3, "cm")
  grid.arrange(
    p1 + opts(legend.position="none"),
    p2 + opts(legend.position="none"),
    legend=legend, main ="", left = "")
  </code></pre>
  
  <h1>Output</h1>
  
  <p><img src="https://i.stack.imgur.com/dAm9F.png" alt="Example image"></p>