Graphics Reference
In-Depth Information
Figure . . A demonstration of grid viewports. he overall data region (bounded by the axes)is
a viewport, each overall thermometer is another viewport, and the black region within each
thermometer is yet another viewport. he white text within each thermometer is also drawn within its
own (clipped) viewport
We draw a rectangle around this new viewport and then draw the word 'thermome-
ter'.
> grid.rect(gp=gpar(fill="white"))
> grid.text("thermometer",
y=0, just="left", rot=90)
Wecreateyetanotherviewport,whichisjustthebottom %ofthesecondviewport,
and draw a filled rectangle within that.
> pushViewport(viewport(height=0.3, y=0,
just="bottom"))
> grid.rect(gp=gpar(fill="black"))
Finally, we create a viewport in exactly the same location as the third viewport, but
thistimewith clippingturned;whenwedrawtheword'thermometer' againinwhite,
it is only drawn within the filled black rectangle.
> pushViewport(viewport(clip=TRUE))
> grid.text("thermometer",
y=0, just="left", rot=90,
gp=gpar(col="white"))
A second thermometer has been drawn in a similar manner in Fig. . (code not
shown).
his sort of facility provides great power and flexibility for producing complex
plots such as the Trellis plots produced by the lattice system (Fig. . ) and more be-
sides.
Search WWH ::




Custom Search