widthSpec: Specify the width of a variable-width line

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/width.R

Description

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.

Usage

1
2
3
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)

Arguments

x

A numeric vector or a unit specifying the width, or a list of such with components left and right specifying the width to either side.

default.units

The units to use if x or w is specified as a numeric vector.

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.

Details

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.

Value

widthSpec creates a "widthSpec" object.

widthSpline creates a "widthSpline" object.

BezierWidth creates a "BezierWidth" object.

Author(s)

Paul Murrell

See Also

grid.xspline, grid.curve, grid.vwline, grid.vwcurve, grid.brushXspline, grid.vwXspline, grid.offsetXspline, grid.offsetBezier

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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"))

vwline documentation built on July 25, 2019, 9:03 a.m.

Related to widthSpec in vwline...