Add Horizontal Arrow with Text Label to a ggplot

add_h_arrow(
  p,
  x,
  y,
  label = "optimal number",
  space = 0.01,
  vjust = 0.3,
  seg_len = 0.1,
  arrow_len = unit(2, "mm"),
  arrow_type = c("closed", "open"),
  font_size = 5,
  font_family = c("serif", "sans", "mono"),
  font_face = c("plain", "bold", "italic")
)

Arguments

p

a ggplot.

x

position at x axis.

y

position at y axis.

label

text label.

space

a small space between arrow and text.

vjust

vertical adjustment, set to 0 to align with the bottom, 0.5 for the middle, and 1 (the default) for the top.

seg_len

length of the arrow segment.

arrow_len

length of the arrow.

arrow_type

type of the arrow.

font_size

font size.

font_family

font family.

font_face

font face.

Value

a ggplot object.