wedges: Add Wedge-Shaped Line Segments to a Plot

Description Usage Arguments See Also Examples

View source: R/wedges.R

Description

Draw wedge-shaped line segments between pairs of points.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
wedges(
  x0,
  y0,
  x1,
  y1,
  ybase = 0.03 * diff(par("usr")[3:4]),
  pborder = NA,
  pcol = "darkgray",
  ...
)

Arguments

x0

Numeric vector of x coordinates from which to draw the wide base of the wedges.

y0

Numeric vector of y coordinates from which to draw the wide base of the wedges. Must be the same length as x0.

x1

Numeric vector of x coordinates to which to draw the narrow point of the wedges. Must be the same length as x0.

y1

Numeric vector of y coordinates to which to draw the narrow point of the wedges. Must be the same length as x0.

ybase

Numeric vector giving the width of the wedge bases in y-scale units, default 3 length as x0.

pborder

Vector of colors to draw the borders of the wedges. The default, NA, omits borders. Must be of length 1 or the same length as x0. See polygon.

pcol

Vector of colors to fill the wedges, default "darkgray". Must be of length 1 or the same length as x0. See polygon.

...

Additional arguments to polygon.

See Also

segments, arrows, polygon.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
df <- data.frame(x=runif(5, 0, 1), y=runif(5, 0, 10))

# draw a single wedge
plot(df)
with(df, wedges(x[1], y[1], x[2], y[2], ybase=1))

# draw several wedges from point to point
s <- seq(length(df$x)-1)
plot(df)
with(df, invisible(lapply(s, function(i)
 wedges(x[i], y[i], x[i+1], y[i+1], pborder=(5:2)[i], pcol=(2:5)[i])
)))

JVAdams/jvamisc documentation built on Aug. 11, 2021, 6:43 a.m.