widthSpec | R Documentation |
Specify the width of a variable-width line. The
widthSpline
and BezierWidth
functions are for use with
grid.brushXspline
or grid.offsetXspline
or
grid.offsetBezier
.
The widthSpec
function is for use with
grid.vwline
.
widthSpec(x, default.units = "npc")
widthSpline(w=unit(1, "cm"), default.units="in", d=NULL, shape=-1, rep=FALSE)
BezierWidth(w=unit(1, "cm"), default.units="in", d=NULL, rep=FALSE)
x |
A numeric vector or a unit specifying the width,
or a list of such with components
|
default.units |
The units to use if |
w |
A numeric vector or a unit specifying the width. |
d |
A numeric vector or a unit specifying the distance along the line for each width value. |
shape |
The shape parameter for the width spline. |
rep |
A logical indicating whether to repeat the widths along the full length of the line. |
All variable-width functions accept width as just a numeric vector or a unit; the former is automatically converted to the latter.
For grid.vwcurve
and grid.vwXspline
, each width
is associated with an x/y location on the main curve.
The grid.vwline
function is similar except that,
via widthSpec
, it
also allows the width to be different on either side of the
main curve.
For grid.brushXspline
and grid.offsetXspline
,
the width is independent of the x/y locations that specify the main
curve. The width is itself a spline, with each width associated
with a distance along the length of the main curve. By default,
the specified widths are spaced evenly along the main curve, but
the widthSpec
function allows fine control over the
spacing of the widths.
For BezierWidth
, w
must contain 4 (or 7 or 10)
values to provide an appropriate number of control points, although
a single value is automatically replicated four times.
If d
is specified, the same rules apply.
widthSpec
creates a "widthSpec"
object.
widthSpline
creates a "widthSpline"
object.
BezierWidth
creates a "BezierWidth"
object.
Paul Murrell
grid.xspline
,
grid.curve
,
grid.vwline
,
grid.vwcurve
,
grid.brushXspline
,
grid.vwXspline
,
grid.offsetXspline
,
grid.offsetBezier
grid.newpage()
x <- c(.2, .4, .6, .8)
y <- c(-.05, .05, -.05, .05)
grid.vwcurve(x, y + .8, w=c(0, .1, 0, .1))
grid.lines(x, y + .8, gp=gpar(col="white"))
grid.vwline(x, y + .6, w=widthSpec(list(left=c(0, .1, 0, .1),
right=c(.1, 0, .1, 0))))
grid.lines(x, y + .6, gp=gpar(col="white"))
grid.brushXspline(verticalBrush, x, y + .4,
w=widthSpline(c(0, .1, 0, .1), "npc", shape=1))
grid.xspline(x, y + .4, shape=1, gp=gpar(col="white"))
grid.offsetXspline(x, y + .2,
w=widthSpline(c(0, .1, 0, .1, 0), "npc",
d=0:4/8, shape=1, rep=TRUE))
grid.xspline(x, y + .2, shape=1, gp=gpar(col="white"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.