title: R: print multiple types of plots on one page
body: <p>I am trying to plot multiple plots in one page. I know functions like <code>gridExtra::grid.arrange</code> that can plot graphs generated by <code>ggplot2</code> package. The problem I am facing is that I have two plots (<code>bar.plot</code> and <code>density.plot</code> below) that are generated by <code>ggplot2</code> package and one plot generated using <code>limma::vennDiagram</code> function. I have tried the below but it is not working:</p>
  
  <pre><code>output &lt;- paste('summary.pdf')
  pdf(output,width = 25,height = 20)
  par(mfrow = c(3, 3))
  plot(bar.plot)
  plot(density.plot)
  print(vennDiagram(dat.venn, circle.col = col,cex = c(3,3,3)))
  invisible(dev.off())
  </code></pre>
  
  <p>dat.venn is a data of type VennCounts:</p>
  
  <pre><code> I-H-10003-T1-D1 I-H-10003-T2-D1 I-H-10003-T3-D1 Counts
                 0               0               0      0
                 0               0               1     41
                 0               1               0     81
                 0               1               1     66
                 1               0               0     10
                 1               0               1      2
                 1               1               0      4
                 1               1               1     56
  attr(,"class")
  [1] "VennCounts"
  </code></pre>
  
  <p>I am unable to find a venn diagram package that is compatible with the <code>grid.arrange</code> function. I don't think that <code>VennCounts</code> cant be printed out with <code>grid.arrange</code> function and <code>ggplot2</code> plots can be printed out with <code>par</code> function.</p>
  
  <p>UPDATE: 
  I tried using pushViewport but it is still printing the venn diagram on the next page:</p>
  
  <pre><code>pdf(output,width = 25,height = 20)
  
  # Create layout : nrow = 2, ncol = 2
  pushViewport(viewport(layout = grid.layout(2, 2)))
  
  # A helper function to define a region on the layout
  define_region &lt;- function(row, col){
    viewport(layout.pos.row = row, layout.pos.col = col)
  } 
  
  # Arrange the plots
  print(bar.plot, vp = define_region(1, 1:2))
  print(density.plot, vp = define_region(2, 1))
  print(vennDiagram(dat.venn, circle.col = col,cex = c(3,3,3)), vp = define_region(2, 2))
  dev.off()
  </code></pre>
  
  <p>Any help would be much appreciated!</p>