This function adds a text annotation layer

stamp_label(
  x = 0,
  y = 0,
  label = "a nice label",
  alpha = 1,
  color = "black",
  fill = "white",
  family = "Times",
  fontface = "bold",
  hjust = 0.5,
  lineheight = 0.85,
  size = 5,
  vjust = 0.5,
  nudge_x = 0,
  nudge_y = 0,
  label.padding = ggplot2::unit(0.5, units = "lines"),
  label.r = ggplot2::unit(0.15, units = "lines"),
  label.size = 0.3,
  parse = FALSE,
  xy = NULL
)

Arguments

label

defaults with a message about use

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

fill

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

family

font family

hjust

horizontal justification, between 0 and 1, defaults to .5

lineheight

spacing between lines if text is wrapped

size

size of text

vjust

vertical justification, between 0 and 1, defaults to .5

nudge_x

Horizontal adjustment to nudge labels by. Useful for offsetting text from points, particularly on discrete scales.

nudge_y

Vertical adjustment to nudge labels by. Useful for offsetting text from points, particularly on discrete scales.

label.padding

Amount of padding around label. Defaults to 0.5 lines.

label.r

Radius of rounded corners. Defaults to 0.15 lines.

label.size

Size of label border, in mm.

parse

If TRUE, the labels will be parsed into expressions and displayed as described in ?plotmath.

xy

a data frame where the first two columns contain x and y positional values

Value

Examples

# labels on a plot library(ggplot2) ggplot(cars) + aes(speed, dist) + geom_point() + stamp_label(x = 20, y = 10) + stamp_label(label = "hi", y = c(100, 75, 50), x = 5, fill = "cadetblue2", label.size = 0)
# label on a canvas ggcanvas() + stamp_label()