Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在R中的一个PDF页面上打印多个绘图_R_Pdf_Plot - Fatal编程技术网

在R中的一个PDF页面上打印多个绘图

在R中的一个PDF页面上打印多个绘图,r,pdf,plot,R,Pdf,Plot,我试图在一个PDF页面上绘制4个图表。直到现在,我得到的唯一输出是每页1个文件。我想把它们都放在一页上。一个地块存储在“c”中,其他三个地块使用循环生成。以下是我使用的代码: pdf("path_to_file.pdf", onefile = TRUE) plot(c) for (exp in expL) { plot(plot_list[[exp]]) } dev.off 我尝试不使用“onefile”规范,或添加: par(mfrow=c(2,2)) 甚至 lay

我试图在一个PDF页面上绘制4个图表。直到现在,我得到的唯一输出是每页1个文件。我想把它们都放在一页上。一个地块存储在“c”中,其他三个地块使用循环生成。以下是我使用的代码:

pdf("path_to_file.pdf", onefile = TRUE)
plot(c)
for (exp in expL) {
  plot(plot_list[[exp]])
}
dev.off
我尝试不使用“onefile”规范,或添加:

par(mfrow=c(2,2))
甚至

layout(matrix(c(1,2,3,4), ncol = 2, byrow = TRUE))
但是没有什么帮助

如果能得到一些帮助,我将不胜感激。
多谢各位

c
的绘图类型应与expL相同

如果是,请执行以下操作:

library(cowplot)
plot_grid( append( list(c), expL ), nrow=2 )

expL和c都是使用ggplot/geom_-bar生成的,如果您的意思是这样的话。我真的不明白如何使用“plot_list(append(list(c),expL))”。我得到一个错误输出,告诉我“plot_list”不是我使用的函数,因为代码中有它。将其更改为确实存在的内容。