我需要帮助将图形处理成多个pdf页面。这是我的当前代码:
file <- read.csv(file="file.csv")
library(ggplot2)
library(gridExtra)
library(plyr)
gg1 <- ggplot() +
geom_line(aes(x=TIME, y=var1, colour = "z1"), file) +
geom_line(aes(x=TIME, y=var2, colour = "z2"), file) +
geom_point(aes(x=TIME, y=var3), file) + facet_wrap( ~ ID, ncol=5)+
xlab("x") +
ylab("Y") +
ggtitle(" x ") + scale_colour_manual(name="Legend",
values=c(z1="red", z2 ="blue")) + theme(legend.position="bottom")
gg10 = do.call(marrangeGrob, c(gg1, list(nrow=4, ncol=4)))
ggsave("need10.pdf", gg10)
以下是未分割图像创建的图像
我希望有一段代码,能将我的图表以4x4的布局显示在多个页面上。我的代码最后两行需要调整,但我不知道如何自己解决。
multi.plot <- marrangeGrob(grobs = gg1, nrow = 2, ncol = 2, top = quote(paste(gg1$labels$title,'\nPage', g, 'of', pages))) pdf('Example_marrangeGrob.pdf', w = 12, h = 8) print(multi.plot) dev.off()
,但是收到了错误信息“Error in gList(data = list(wrapvp = list(x = 0.5, y = 0.5, width = 1, : only 'grobs' allowed in "gList"”。有没有办法解决这个问题? - Monklife