0
我使用grid.arrange()绘制一列四个折线图。如果尺寸很大,则将文件保存为.png或.pdf时,grobs看起来不错。但是,当我缩小剧情的高度时,顶部的grob会被压缩。使用autoplot预防grid.arrange压缩grobs
如何防止grid.arrange压缩grobs?
一些丑陋的代码:
(a<-autoplot(mars.prcp1yrs) + labs(y="", x="") +theme_light()+ylim(60,210)+
theme(text=element_text(size=8),
axis.text.y=element_text(size=8),axis.text.x=element_blank(),
axis.title.y=element_blank(),
axis.ticks.x=element_blank(),
plot.margin=unit(c(0.1,0.1,0.1,0.1),"in")))
(b<-autoplot(jupiter.prcp1yrs) + labs(y="",x="")+ theme_light()+ylim(60,210)+
theme(text=element_text(size=8),axis.text.y=element_text(size=8),
axis.text.x=element_blank(),axis.title.y=element_blank(),
axis.ticks.x=element_blank(),plot.margin=unit(c(-0.3,0.1,0.1,0.1),"in")))
(c<-autoplot(saturn.prcp1yrs) +labs(y="",x="") + theme_light()+ylim(60,210)+
theme(text=element_text(size=8),
axis.text=element_text(size=8),
axis.text.x=element_blank(),axis.title.y=element_blank(),
axis.ticks.x=element_blank(),plot.margin=unit(c(-0.3,0.1,0.1,0.1),"in")))
(d<-autoplot(earth.prcp1yrs) +labs(y="",x="") +theme_light()+ylim(60,210)+
theme(text=element_text(size=8),axis.text=element_text(size=8),
axis.ticks.x=element_blank(),axis.title.y=element_blank(),
plot.margin=unit(c(-0.3,0.1,0.1,0.1),"in")))
prcp.grid<-grid.arrange(a,b,c,d, ncol=1)
png("plot.png",width=3740,height=1000,res=500)
old.par <- par(mfrow=c(2, 2))
grid.arrange(prcp.grid, ncol=2)
par(old.par)
dev.off()
这里是输出 (I使用该纵横比只是戏剧化顶端GROB的压缩。):
**可再现的例子**。 'fl.idaho.prcp1yrs'这是什么?使用'dput()' – Masoud
这是一个拥有80年日常降水量数据的动物园对象。有没有办法减少输出量? – SoilSciGuy
请阅读[如何在R中创建一个很好的重现示例](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – Masoud