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