gridBase (version 0.4-3)

baseViewports: Generate grid Viewports from Base Plot

Description

This will generate a list of grid viewports which correspond to the current inner, figure, and plot regions of the current base plot.

Usage

baseViewports()

Arguments

Value

  • A list with three elements:
  • innerA viewport corresponding to the inner region of the current plot.
  • figureA viewport corresponding to the figure region of the current plot.
  • plotA viewport corresponding to the plot region of the current plot.

Warning

If you resize the device, all bets are off!

Details

The figure region is relative to the inner region so you must push the inner region before pushing the figure region. Similarly, the plot region is relative to the figure region so this should only be pushed after the previous two.

See Also

Grid, viewport

Examples

Run this code
par(oma=rep(1, 4), mfrow=c(1, 2), xpd=NA)
plot(1:10)
vps <- baseViewports()
pushViewport(vps$inner)
grid.rect(gp=gpar(lwd=3, col="red"))
pushViewport(vps$figure)
grid.rect(gp=gpar(lwd=3, col="green"))
pushViewport(vps$plot)
grid.rect(gp=gpar(lwd=3, col="blue"))
grid.points(1:10, 10:1)

Run the code above in your browser using DataCamp Workspace