rect_shade: Create adjacent rectangular polygons

Description Usage Arguments Details Value Examples

Description

Generic function to create adjacent rectangular polygons from vectors of coordinates passed to it

Usage

1
rect_shade(x, y, fillcol = "grey", linecol = "black", lwd = 1)

Arguments

x

Vector of x coordinates, arranged in ascending order

y

Vector of y coordinates, arrange in acending order

fillcol

A 1 to n - 1 length vector of colors for filling. n = length of x or y (the longest)

linecol

A 1 to n - 1 length vector of polygon border colors. n = length of x or y (the longest)

Details

This is modeled on the rect_coords function used by flex_legend, but the resulting polygon can be of arbitrary shape. It can be used to make either a horizontal (i.e. a sequence of polygons separated on the X-axis, with the long dimension filling the Y-axis) or vertical chain of polygons (the opposite). To make the former, provide a vector giving the X-coordinates separating each polygon, and a 2 parameter vector specifying the lower and upper Y coordinates. For the opposite case, give the left and right X coordinates to X, and a vector of Y coordinates to Y.

Value

A polygon "chain": segmented polygons with interior vertical x or horizontal y axis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
a <- c(-50, -25, 0, 25, 50)
b <- c(-1, 21)
plot(c(-100, 100), c(-1, 22), pch = "")
rect_shade(b, a)

plot(c(-100, 100), c(-1, 22), pch = "")
rect_shade(a, b)

cols <- sapply(c(0.8, 0.5, 0.2, 0.1), function(x) rgb(1, 0, 0, alpha = x))
plot(c(-1, 22), c(-100, 100), pch = "")
# rect_shade(b, a, fillcol = cols)
rect_shade(b, a, fillcol = cols, linecol = cols)

PrincetonUniversity/lmisc documentation built on May 8, 2019, 3:23 a.m.