arrows2: Add filled arrows to a plot

View source: R/plot_extra.R

arrows2R Documentation

Add filled arrows to a plot

Description

Draw filled arrows between pairs of points.

Usage

arrows2(
  x0,
  y0,
  x1 = x0,
  y1 = y0,
  size = 1,
  width = 0.1/cin,
  curve = 1,
  code = 2L,
  col = par("fg"),
  lty = par("lty"),
  lwd = par("lwd"),
  fill = col,
  border = fill,
  sadj = c(0, 0, 0, 0),
  ...
)

Arguments

x0, y0

coordinates of points from which to draw

x1, y1

coordinates of points to which to draw

size, width

size parameters for arrows

curve

a numeric value greater than 0 giving the curvature of the arrows; default is 1 for staight lines, but values less than or greater than 1 may be given for

code

integer determining kind of arrows to be drawn; arrows are drawn at {x0[i], y0[i]}, {x1[i], y1[i]}, or both for code = 1:3, respectively, or no heads drawn if code = 0

col, lty, lwd

color, line type, and line width of the segment

fill, border

fill and border color of arrow

sadj

optional vector of the form {x0,y0,x1,y1} for adjusting the segments of the arrows

...

additional graphical parameters passed to segments and further to par

Author(s)

Original: Andreas Ruckstuhl, 19 May 1994; Cosmetic: Martin Machler, June 1998; Modifications: Robert Redd

See Also

arrows; carrows; https://github.com/cran/sfsmisc

Examples

plot.new()
plot.window(c(-pi, pi), c(-1,1), asp = 1)
curve(sin(x), -pi, pi, add = TRUE)
xx <- seq(-pi, pi, length.out = 5)

## arrows point to locations
arrows2(xx, sin(xx), xx + 0, sin(xx + 0))

## arrows "follow" along curve
arrows2(xx, sin(xx), xx + .1, sin(xx + .1), col = 5, border = 2)

arrows2(-3,-1,3,1, code = 3, border = 2, fill = 0)
arrows2(-2, -1, -2, 1, code = 1, fill = 4, col = 4)
arrows2(-1, -1, -1, 1, code = 2, fill = 2, size = .5, width = .5)
arrows2(0, -1, 0, 1, code = 3, curve = 1.5)
arrows2(1, -1, 1, 1, code = 3, curve = .5, width = .5, lwd = 10, col = 3)
arrows2(2, -1, 2, 1, code = 3, lwd = 0)


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