title: R; plotting scatter plot and heat map side by side
body: <p>I am trying to create an image showing a scatter plot and a heat map side by side. I create the scatter plot with geom_point and the heatmap with heatmap.2. I then use grid.draw to put them in the same image HOWEVER I cannot get the images to be the same size. How can I make sure they are the same height (this is important as they are ordered the same way and match each other)?</p>
  
  <p>The code I have is:</p>
  
  <pre><code>    grab_grob &lt;- function(){
         grid.echo()
         grid.grab()
    }
    g1 &lt;- ggplot(x, aes(x=VIPscore, y=reorder(metabolite, VIPscore))) + geom_point(colour="blue") + labs(y="", x="VIP score")
    heatmap.2(xhm, cexRow=0.5, cexCol=1, Colv=FALSE, Rowv = FALSE, keep.dendro = FALSE, trace="none", key=FALSE, lwid = c(0.5, 0.5), col=heat.colors(ncol(xhm)))  
    g2 &lt;- grab_grob()
    grid.newpage()
    lay &lt;- grid.layout(nrow = 1, ncol=2)
    pushViewport(viewport(layout = lay))
    print(g1,vp=viewport(layout.pos.row = 1, layout.pos.col = 1))
    grid.draw(editGrob(g2, vp=viewport(layout.pos.row = 1, layout.pos.col = 2, clip=TRUE)))
    upViewport(1)
  </code></pre>
  
  <p>I have also tried the geom_tile (instead of heatmap.2) followed by grid.arrange; although the images now match in size colors are awful - they look flat across my data set.</p>