Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I obtain an 'unbalanced' grid of ggplots?
    primarykey
    data
    text
    <p>With <code>grid.arrange</code> I can arrange multiple <code>ggplot</code> figures in a grid to achieve a multi-panel figure by using something like:</p> <pre><code>library(ggplot2) library(grid) library(gridExtra) </code></pre> <p>generate some ggplot2 plots , then</p> <pre><code>plot5 &lt;- grid.arrange(plot4, plot1, heights=c(3/4, 1/4), ncol=1, nrow=2) </code></pre> <p>How can I obtain an 'unbalanced' 2 col layout with one plot in the entire first col and three plots in the second col? I toyed with a 'grid-of-grids' approach by trying to use <code>grid.arrange</code> to plot one grid (e.g. <code>plot5</code>, above) against another plot, but obtained:</p> <blockquote> <p>Error in arrangeGrob(..., as.table = as.table, clip = clip, main = main, : input must be grobs!</p> </blockquote> <p><strong>Update:</strong></p> <p>Thanks for the advice. I will look into <code>viewports</code> and <code>grid</code>. In the meantime, thanks to @DWin, the <code>layOut</code> function in the 'wq' package worked very well for the compilation figure in my <code>Sweave</code> document: <img src="https://i.stack.imgur.com/ECZdb.png" alt="enter image description here"></p> <p><strong>Update 2:</strong></p> <p>The <code>arrangeGrob</code>command (as suggested by @baptiste) also works well, and seems very intuitive - at least it was easy to alter widths of the two columns. It also has the benefit of not requiring the `wq' package. </p> <p>e.g. Here is the code from my Sweave file:</p> <pre><code>&lt;&lt;label=fig5plot, echo=F, results=hide&gt;&gt;= plot5&lt;-grid.arrange(plot4, arrangeGrob(plot1, plot2, plot3, ncol=1), ncol=2, widths=c(1,1.2)) @ \begin{figure}[] \begin{center} &lt;&lt;label=fig5,fig=TRUE,echo=T, width=10,height=12&gt;&gt;= &lt;&lt;fig5plot&gt;&gt; @ \end{center} \caption{Combined plots using the `arrangeGrob' command.} \label{fig:five} \end{figure} </code></pre> <p>which produces the following output: <img src="https://i.stack.imgur.com/043sb.png" alt="enter image description here"></p> <p>BTW, Anyone tell me why the '>NA' appears?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload