grid (version 3.0.3)

grid.force: Force a grob into its components

Description

Some grobs only generate their content to draw at drawing time; this function replaces such grobs with their at-drawing-time content.

Usage

grid.force(redraw = TRUE) grid.revert(redraw = TRUE)

Arguments

redraw
logical value indicating whether to redraw the grid scene after the forcing operation.

Note

These functions only have an effect for grobs that generate their content at drawing time using makeContext() and makeContent() methods (not for grobs that generate their content at drawing time using preDrawDetails() and drawDetails() methods).

Details

Some grobs wait until drawing time to generate what content will actually be drawn (an axis, as produced by grid.xaxis(), with an at or NULL is a good example because it has to see what viewport it is going to be drawn in before it can decide what tick marks to draw).

The content of such grobs (e.g., the tick marks) are not usually visible to grid.ls() or accessible to grid.edit().

The grid.force() function replaces a grob with its at-drawing-time contents. For example, an axis will be replaced by a vanilla gTree with lines and text representing the axis tick marks that were actually drawn. This makes the tick marks visible to grid.ls() and accessible to grid.edit().

The grid.revert() function reverses the effect of grid.force(), replacing forced content with the original grob.

Examples

Run this code
grid.newpage()
pushViewport(viewport(width=.5, height=.5))
grid.xaxis()
grid.ls()
grid.force()
grid.ls()
grid.revert()
grid.ls()

Run the code above in your browser using DataCamp Workspace