我有一个两行的数字,由第一行的情节和第二行的情节列表组成。
knitr
我做
\documentclass{article}
\begin{document}
<<plots, fig.width='\\textwidth', echo = FALSE, fig.height=5, fig.width = 10, warning = FALSE>>=
require(ggplot2)
plot <- ggplot() + geom_point(data=cars, aes(speed, dist)) + labs(x=NULL, y=NULL)
# create plot with function
makePlot <- function(myLabel) {
ggplot() + geom_point(data=cars, aes(speed, dist)) + labs(x=NULL,y=NULL,title=myLabel)
}
list_plot <- lapply(c("one","two","three"), makePlot)
require(gridExtra)
grob <- do.call(grid.arrange, c(list_plot, nrow=1, ncol=3)) # here R sends the plots to the graphical device!
grid.arrange(plot,
grob,
nrow=3)
@
\end{document}
产生
问题在于我do.call
我的图表列表,它会立即向图形设备发送图表。
是否可以在knitr
或在将do.call
传递到grob
时避免python manage.py changepassword mickey
吐出图片时对此进行修复?
答案 0 :(得分:4)
使用??grid.arrange
,我们会找到arrangeGrob
的帮助页面。这指定了以下内容:
- arrangeGrob:返回没有绘图的grob
- grid.arrange:在当前设备上绘图
- marrangeGrob:可以在多个页面上发送的arrangeGrob接口
因此,解决方案是使用arrangeGrob
代替grid.arrange
。
另一个好处是可以使用grobs
参数传递一个grob列表,这样我们就可以取消do.call
构造。