是否可以在grid
包中“强制”R 基图grid.newpage
?例如,这很好用:
library(grid)
grid.newpage()
vp1 <- viewport(x=0,y=0.5,width=0.5, height=0.5, just = c("left", "bottom"))
vp2 <- viewport(x=0.5,y=0,width=0.5, height=0.5, just = c("left", "bottom"))
pushViewport(vp1)
grid.rect()
grid.text("vp1", 0.5, 0.5)
upViewport()
pushViewport(vp2)
grid.rect()
grid.text("vp2", 0.5, 0.5)
.
但如果我尝试这样的事情:
grid.newpage()
vp1 <- viewport(x=0,y=0.5,width=0.5, height=0.5, just = c("left", "bottom"))
vp2 <- viewport(x=0.5,y=0,width=0.5, height=0.5, just = c("left", "bottom"))
pushViewport(vp1)
grid.rect()
print(plot(1,2))
grid.text("vp1", 0.5, 0.5)
upViewport()
pushViewport(vp2)
grid.rect()
print(plot(1,2))
R 基础图只是覆盖了grid.newpage
. 使用par(new=T)
也无济于事。