This function adds an arrow annotation layer Contribute or help document https://github.com/EvaMaeRey/ggstamp/blob/master/R/stamp_arrow.R

stamp_arrow(
  x = 0,
  y = 0,
  xend = 1,
  yend = 1,
  alpha = 1,
  color = "black",
  linetype = "solid",
  size = 1.5,
  ends = "last",
  units = "npc",
  headlength = 0.03,
  headangle = 30,
  headtype = "open",
  lineend = "butt",
  linejoin = "round",
  arrow.fill = T
)

Arguments

x

numeric x position, defaults to 0

y

numeric y position, defaults to 0

xend

numeric x end position, defaults to 1

yend

numeric y end position, defaults to 1

alpha

numeric between 0 and 1 indicating transparency, defaults to 1 fully opaque, zero is fully transparent

color

a character string indicating color, defaults to "black", for other named colors check out https://evamaerey.github.io/ggplot2_grammar_guide/named_colors

linetype

a string indicating linetype, "solid", "dashed", "dotted", defaults to "solid"

size

numeric value indicating line width, defaults to 1.5

ends

a character string, one of "last", "first", or "both", indicating which ends of the line to draw arrow heads, defaults to last

units

A character vector specifying the units for head length, default is "npc" for native plot coordinates

headlength

A numeric value specifying the length of the arrow head (from tip to base), defaults to .03

headangle

A numeric value, the angle of the arrowhead in degrees (smaller numbers produce narrower, pointier arrows). Essentially describes the width of the arrow head.

headtype

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

lineend

Line end style (round, butt, square)

linejoin

Line join style (round, mitre, bevel)

arrow.fill

fill colour to use for the arrow head (if closed). NULL means use colour aesthetic.

Value

Examples

# stamp arrow on plot library(ggplot2) ggplot(cars) + aes(speed, dist) + geom_point() + stamp_arrow() + stamp_arrow(color = "darkred", xend = 15, yend = 75)
# several arrows ggcanvas() + stamp_arrow(color = "steelblue") + stamp_arrow(x = 1:5, y = 2, xend = 2:6, headlength = .04, headtype = "closed", color = "darkred") + stamp_arrow(x = .5, xend = 1.5, ends = "both", headangle = 60)