Draws an arrow between two points in the scplot.

add_arrow(
  object,
  case = 1,
  x0,
  y0,
  x1,
  y1,
  color = "black",
  angle = 30,
  length = 5,
  type = "open",
  ends = "last",
  linewidth = 0.7
)

Arguments

object

An scplot object (class scplot) returned from the scplot() function.

case

Numerical vector with the case number or character string. case = "all" for all cases.

x0

Origin x position of the line.

y0

Origin y position of the line.

x1

End x position of the line.

y1

End y position of the line.

color

A character string or a number defining the color of an element.

angle

Angle (in [0,360])

length

Size of the arrow angels. Can be specified as a numeric value (in points) or as a unit object (e.g., unit(5, "points")).

type

One of "open" or "closed" indicating whether the arrow head should be a closed triangle.

ends

One of "last", "first", or "both", indicating which ends of the line to draw arrow heads.

linewidth

A number with the width of the line.

Value

An object of class scplot (see scplot()) with added element lines.

Details

The arrow is drawn from point (x0, y0) to point (x1, y1). The arrow head can be customized with the arguments angle, length, type, and ends. The angle argument specifies the angle of the arrow head, while length specifies the size of the arrow head. The type argument indicates whether the arrow head should be an open or closed triangle, and the ends argument specifies which ends of the line should have arrow heads (last, first, or both). The color and linewidth arguments control the appearance of the arrow line. Note that the length argument can be specified as a numeric value (in points) or as a unit object (e.g., unit(5, "points")).

Examples

data(exampleAB, package = "scan")
p1 <- scplot(exampleAB$Anja)  |>
  add_arrow(case = 1, 2, 70, 6, 55, color = "darkred")