随着grid.arrange我可以安排多个ggplot在网格中人物使用类似,实现了多屏图:
library(ggplot2)
library(grid)
library(gridExtra)
Run Code Online (Sandbox Code Playgroud)
然后生成一些ggplot2图
plot5 <- grid.arrange(plot4, plot1, heights=c(3/4, 1/4), ncol=1, nrow=2)
Run Code Online (Sandbox Code Playgroud)
如何获得"不平衡"2 col布局,其中第一个col中有一个绘图,第二个col中有三个绘图?我玩弄了一个'网格网格'方法,试图用grid.arrange一个网格(例如plot5,上面)绘制另一个图,但得到了:
在ArrangeGrob中出错(...,as.table = as.table,clip = clip,main = main,:输入必须是grobs!
更新:
感谢您的建议.我会考虑viewports和grid.与此同时,感谢@DWin,layOut'wq'包中的函数非常适合我Sweave文档中的编译图:

更新2:
该arrangeGrob命令(由@baptiste建议)也运行良好,看起来非常直观 - 至少很容易改变两列的宽度.它还具有不需要`wq'包的好处.
这是我的Sweave文件中的代码:
<<label=fig5plot, echo=F, results=hide>>=
plot5<-grid.arrange(plot4, arrangeGrob(plot1, plot2, plot3, ncol=1),
ncol=2, widths=c(1,1.2))
@
\begin{figure}[]
\begin{center}
<<label=fig5,fig=TRUE,echo=T, width=10,height=12>>=
<<fig5plot>>
@
\end{center}
\caption{Combined plots using the `arrangeGrob' command.}
\label{fig:five}
\end{figure}
Run Code Online (Sandbox Code Playgroud)
产生以下输出:

顺便说一下,有人告诉我为什么出现'> NA'?
bap*_*ste 70
grid.arrange直接在设备上绘制; 如果你想将它与你需要的其他网格对象结合起来arrangeGrob,就像在
p = rectGrob()
grid.arrange(p, arrangeGrob(p,p,p, heights=c(3/4, 1/4, 1/4), ncol=1),
ncol=2)
Run Code Online (Sandbox Code Playgroud)
编辑(07/2015):使用v> 2.0.0,您可以使用layout_matrix参数,
grid.arrange(p,p,p,p, layout_matrix = cbind(c(1,1,1), c(2,3,4)))
Run Code Online (Sandbox Code Playgroud)
42-*_*42- 17
我尝试用网格计算它,并认为我把它弄下来但最终失败了(虽然现在看看我在下面引用的函数中的代码,我可以看到我真的很接近...... :-)
'wq'包有一个layOut可以为你做的功能:
p1 <- qplot(mpg, wt, data=mtcars)
layOut(list(p1, 1:3, 1), # takes three rows and the first column
list(p1, 1, 2), # next three are on separate rows
list(p1, 2,2),
list(p1, 3,2))
Run Code Online (Sandbox Code Playgroud)
