Is it possible to βforceβ the basic R graphs in the grid grid.newpage package? For example, this works great:
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)
.
But if I try something like this:
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))
The R base stretch simply overloads grid.newpage . Using par(new=T) doesn't help either.