Purpose
To use seekViewport in the code to push view ports.

Using seekViewport helps the user avoid popViewport, pushViewport etc .

> grid.newpage()
> x <- runif(10)
> y <- runif(10)
> xscale <- range(x) + c(-1, 1) * diff(range(x)) * 0.05
> yscale <- range(y) + c(-1, 1) * diff(range(y)) * 0.05
> top.vp <- viewport(layout = grid.layout(3, 3, widths = unit(c(5,
+     1, 2), c("lines", "null", "lines")), heights = unit(c(5,
+     1, 4), c("lines", "null", "lines"))))
> margin1 <- viewport(layout.pos.col = 2, layout.pos.row = 3, name = "margin1")
> margin2 <- viewport(layout.pos.col = 1, layout.pos.row = 2, name = "margin2")
> margin3 <- viewport(layout.pos.col = 2, layout.pos.row = 1, name = "margin3")
> margin4 <- viewport(layout.pos.col = 3, layout.pos.row = 2, name = "margin4")
> plot <- viewport(layout.pos.col = 2, layout.pos.row = 2, name = "plot",
+     xscale = xscale, yscale = yscale)
> splot <- vpTree(top.vp, vpList(margin1, margin2, margin3, margin4,
+     plot))
> pushViewport(splot)
> seekViewport("plot")
> grid.points(x, y)
> grid.xaxis()
> grid.yaxis()
> grid.rect()
> seekViewport("margin1")
> grid.text("Random X", y = unit(1, "lines"))
> seekViewport("margin2")
> grid.text("Random Y", x = unit(1, "lines"), rot = 90)
> upViewport(0)
> seekViewport("margin3")
> grid.text("Scatterplot from scratch", gp = gpar(fontsize = 20))

seekViewport-001.jpg