carrows: Curved arrows

View source: R/plot_extra.R

carrowsR Documentation

Curved arrows

Description

Draw an arrow along the arc of a circle.

Usage

carrows(
  p1,
  p2,
  arc,
  degree = FALSE,
  pad = 0.01 * 1:2,
  flip = FALSE,
  dir = NULL,
  col = par("col"),
  lwd = par("lwd"),
  lty = par("lty"),
  size = 1,
  width = size/2,
  curve = 1,
  fill = col,
  border = NA
)

Arguments

p1, p2

vectors of length two giving the {x,y} coordinates for two points to draw a connecting arc

arc

a vector of length two with the starting and ending positions to draw the arc, in radians or degrees

degree

logical; if TRUE, arc should be in degrees; however, if either element of arc is greater than 2 * pi, they are assumed to be in degrees and will be converted to radians; set to TRUE to avoid conversion of small angles to radians

pad

a vector of length two giving 1) padding between the tips of the arrow/segment and the points and 2) additional padding between the segment endpoints and tip of arrow–useful for thick lines which may protrude from under the arrowhead

flip

logical; if TRUE, the arrow will be rotated around the circle 180 degrees

dir

optional vector of directions for arrows; by default, arrows will point to the nearest endpoint; dir should be a vector of 1s and -1s and will be recycled as necessary; other values will be ignored and result in no arrows for those positions

col, lwd, lty

color, line width, and line type passed to lines

size, width, curve, fill, border

additional parameters passed to arrows2

Value

A list containing the arc endpoints and the center and radius of the corresponding circle.

See Also

arrows2; xspline

Examples

plot.new()
plot.window(c(-2,2), c(-2,2))
p <- matrix(c(rep(-1:1, 2), rep(-1:1, each = 2)), ncol = 2)
points(p)

carrows(p1 <- p[2, ], p2 <- p[1, ], pad = 0.3)
carrows(p1 <- p[4, ], p2 <- p[5, ], dir = c(0, 1), col = 3)
carrows(p1 <- p[6, ], p2 <- p[3, ], lwd = 10, pad = c(0.05, 0.1))
carrows(p1 <- p[1, ], p2 <- p[6, ], flip = TRUE)
carrows(p1 <- p[1, ], p2 <- p[5, ], dir = c(1, 0))


raredd/plotr documentation built on Nov. 19, 2023, 4:09 a.m.