由于出图需求,需要使用一页多图的方式出图。对照着《GGPLOT2:数据分析与图形艺术》书上的程序方法测试了下,不管的计算方式还是GRID.LAYOUT方式,两种排版方式都出现了同样的错误。代码是
library(RODBC)
library(ggplot2)
library(reshape2)
library(grid)
ot
us
otcy1
a1
b1
b2
c1
c2
vpa1=viewport(width=1,height=0.3,x=0.5,y=0.75)
vpb1=viewport(width=0.5,height=0.3,x=0.25,y=0.45)
vpb2=viewport(width=0.5,height=0.3,x=0.75,y=0.45)
vpc1=viewport(width=0.5,height=0.3,x=0.25,y=0.15)
vpc2=viewport(width=0.5,height=0.3,x=0.75,y=0.15)
pdf("test.pdf",width=8,height=9)
print(a1,vp=vpa1)
print(b1,vp=vpb1)
print(b2,vp=vpb2)
print(c1,vp=vpc1)
print(c2,vp=vpc2)
dev.off()
close(o