Skip to contents

The sketch analogue of ggplot2::annotate(). Creates a one-off layer of fixed, hand-drawn marks that do not inherit the plot's aesthetics — useful for highlighting, callouts, and reference shapes.

Usage

annotate_sketch(
  geom,
  x = NULL,
  y = NULL,
  xmin = NULL,
  xmax = NULL,
  ymin = NULL,
  ymax = NULL,
  xend = NULL,
  yend = NULL,
  r = NULL,
  a = NULL,
  b = NULL,
  seed = NULL,
  na.rm = FALSE,
  ...
)

Arguments

geom

Name of the sketch geom to draw. One of "point", "line", "path", "segment", "rect", "polygon", "circle", "ellipse".

x, y, xmin, xmax, ymin, ymax, xend, yend

Positioning aesthetics (numeric vectors, recycled to a common length). Supply the ones the chosen geom needs (e.g. xmin/xmax/ymin/ymax for "rect", xend/yend for "segment").

r, a, b

Radius ("circle") or semi-axes ("ellipse").

seed

Integer seed for reproducible wobble.

na.rm

If FALSE (default), missing values trigger a warning.

...

Other arguments passed to the underlying geom_sketch_*() layer (e.g. colour, fill, roughness, fill_style).

Value

A ggplot2 layer object.

Examples

library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
  geom_sketch_point(seed = 1L) +
  annotate_sketch("rect", xmin = 3, xmax = 4, ymin = 15, ymax = 22,
                  fill = NA, colour = "red", seed = 2L) +
  annotate_sketch("segment", x = 2, y = 30, xend = 3.5, yend = 20,
                  colour = "blue", seed = 3L) +
  theme_sketch()