且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将多个ggplots打印成一个pdf,每页多个图

更新时间:2023-11-21 09:11:34

This solution is independent of whether the lengths of the lists in the list p are different.

library(gridExtra)

pdf("plots.pdf", onefile = TRUE)
for (i in seq(length(p))) {
  do.call("grid.arrange", p[[i]])  
}
dev.off()

Because of onefile = TRUE the function pdf saves all graphics appearing sequentially in the same file (one page for one graphic).

相关阅读

推荐文章