ggplot list of plots to one pdf with different page layouts

馋奶兔 提交于 2019-12-06 11:30:06

you can use the same class trick as marrangeGrob,

library(ggplot2)
library(gridExtra)
pl <- lapply(1:7, function(i) ggplot() + ggtitle(i))

ppl <- list(p1 = arrangeGrob(grobs=pl[1:4]),
            p2 = arrangeGrob(grobs=pl[5:6]),
            p3 = arrangeGrob(grobs=pl[7]))

class(ppl) <- c("arrangelist", class(pl))

ggsave("multipage.pdf", ppl)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!