有了grid.arrange
我可以ggplot
在一个网格中排列多个图形,通过使用类似的东西来实现一个多面板图形:
library(ggplot2)
library(grid)
library(gridExtra)
生成一些 ggplot2 图,然后
plot5 <- grid.arrange(plot4, plot1, heights=c(3/4, 1/4), ncol=1, nrow=2)
如何获得一个“不平衡”的 2 col 布局,在整个第一个 col 中有一个图,在第二个 col 中有三个图?我通过尝试使用grid.arrange
将一个网格(例如plot5
,上面)与另一个图绘制出来来玩弄“网格网格”方法,但获得了:
安排Grob(...,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}
产生以下输出:
顺便说一句,有人告诉我为什么会出现“> NA”吗?