grid.trim: Subset a Line

View source: R/grid.R

grid.trimR Documentation

Subset a Line

Description

These functions generate one or more lines by subsetting a line.

Usage

trimGrob(x, from, to, rep=FALSE, name=NULL, gp=gpar(), ...) 
grid.trim(x, ...)

Arguments

x

A grob, or a gPath (or a character value) identifying a grob that has already been drawn.

from

A numeric vector or a unit object describing the start point of each subset.

to

A numeric vector or a unit object describing the end point of each subset.

rep

A logical value indicating whether the from and to values should be repeated to consume the entire line.

name

A name for the resulting grob.

gp

Graphical parameter settings for the resulting grob.

...

For trimGrob, arguments passed on to trim. For grid.trim, arguments used by methods.

Details

Both from and to should be either numeric values between 0 and 1, expressing a proportion of the line length, or unit objects. In the latter case, the unit is converted to a proportion of the line length, with "npc" units treated as proportions of the line length.

Both from and to can be vectors (and they are recycled) so that multiple subsets can be obtained in a single call.

Both from and to can be negative, in which case the value is treated as distance backwards along the line from its end.

The result is a new grob. In the case of grid.trim, this new grob will be drawn on the current device. In the special case that x is a gPath, by default, the new grob will replace the old grob (the original grob identified by x) in the current scene (and the new grob will use the same gp settings as the old grob).

Value

trimGrob returns a polyline grob.

grid.trim is only used for its side-effect of drawing on the current graphics device.

Author(s)

Paul Murrell

See Also

trim

Examples

g <- xsplineGrob(c(.2, .5, .8), c(.2, .8, .2))
grid.draw(g)
grid.trim(g, from=.1, to=.2, gp=gpar(lwd=5))
grid.trim(g, from=.1, to=.2, rep=TRUE, gp=gpar(lwd=3))

gridGeometry documentation built on March 21, 2022, 1:05 a.m.