grid.trim | R Documentation |
These functions generate one or more lines by subsetting a line.
trimGrob(x, from, to, rep=FALSE, name=NULL, gp=gpar(), ...)
grid.trim(x, ...)
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 |
name |
A name for the resulting grob. |
gp |
Graphical parameter settings for the resulting grob. |
... |
For |
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).
trimGrob
returns a polyline grob.
grid.trim
is only used for its side-effect of drawing
on the current graphics device.
Paul Murrell
trim
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))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.