[R] Grid: constructing a gTree with grobs that use named viewports from a vpTree

hadley wickham h.wickham at gmail.com
Mon Oct 3 20:50:47 CEST 2005


> But I get:
>
>  Error in downViewport.vpPath(vp, strict = TRUE, recording = FALSE) :
>         Viewport 'tl' was not found
>
> presumably because no equivalent of the upViewport(1) command is used.
>
> What should I be doing here?

I've solved my own problem - I need to use childrenvp instead and
construct a fuller viewport path:

grobs <- gList(
	rectGrob(vp=vpPath("layout","tl")),
	textGrob("Top left", vp=vpPath("layout","tl")),
	textGrob("Bottom right", vp=vpPath("layout","br"))
)

grid.draw(gTree(childrenvp=vp, children = grobs))

Hadley




More information about the R-help mailing list