Learn R Programming

grid (version 3.3.1)

makeContent: Customised grid Grobs

Description

These generic hook functions are called whenever a grid grob is drawn. They provide an opportunity for customising the drawing context and drawing content of a new class derived from grob (or gTree).

Usage

makeContext(x) makeContent(x)

Arguments

x
A grid grob.

Value

Both functions are expected to return a grob or gTree (a modified version of x).

Details

These functions are called by the grid.draw methods for grobs and gTrees.

makeContext is called first during the drawing of a grob. This function should be used to modify the vp slot of x (and/or the childrenvp slot if x is a gTree). The function must return the modified x. Note that the default behaviour for grobs is to push any viewports in the vp slot, and for gTrees is to also push and up any viewports in the childrenvp slot, so this function is used to customise the drawing context for a grob or gTree.

makeContent is called next and is where any additional calculations should occur and graphical content should be generated (see, for example, grid:::makeContent.xaxis. This function should be used to modify the children of a gTree. The function must return the modified x. Note that the default behaviour for gTrees is to draw all grobs in the children slot, so this function is used to customise the drawing content for a gTree. It is also possible to customise the drawing content for a simple grob, but more care needs to be taken; for example, the function should return a standard grid primitive with a drawDetails() method in this case.

Note that these functions should be cumulative in their effects, so that the x returned by makeContent() includes any changes made by makeContext().

Note that makeContext is also called in the calculation of "grobwidth" and "grobheight" units.

See Also

grid.draw