我正在尝试创建多个图的pdf,但pdf只打印前n个图。我使用的是ggforce::facet_wrap_paginate。下面是我写的代码。如果有人能给我任何建议,为什么我只得到前6个情节,我会很高兴?我也尝试过使用PNG,但我也遇到了同样的问题。当它完成时,我期待着一个20-30页(大约160个图)的pdf。所以你可以理解我对6个情节的失望...
pg <- ceiling(
length(levels(Tidy$Region)) / 6
)
pdf("attempt3001.pdf")
for(i in seq_len(pg)){
print(ggplot(Tidy, aes(x=Year, y=Value / 1000, group=Country, color=Status))+
geom_line()+
theme_classic()+
facet_wrap_paginate(~Region, nrow = 3, ncol = 2, page = 1, scales = "free"))
}
dev.off()
我在堆栈上见过类似的问题,但它们是在facet_wrap_paginate出现之前出现的(这太神奇了!)或者没有解决我的问题。在此之前,非常感谢您。
This question就是我对当前代码进行建模的工具。我希望我能对此发表评论,但我没有名气哈哈。
发布于 2018-02-28 21:37:48
问题很简单,您没有绘制每个页面的i
,而只绘制了第一个页面。在您的代码中用page = i
替换page = 1
。
pg <- ceiling(
length(levels(Tidy$Region)) / 6
)
pdf("attempt3001.pdf")
for(i in seq_len(pg)){
print(ggplot(Tidy, aes(x=Year, y=Value / 1000, group=Country, color=Status)) +
geom_line() +
theme_classic() +
facet_wrap_paginate(~Region, nrow = 3, ncol = 2, page = i, scales = "free"))
}
dev.off()
https://stackoverflow.com/questions/49038485
复制相似问题