geom_sketch_text() and geom_sketch_label() add text in a handwriting font,
the sketch counterparts of ggplot2::geom_text() and ggplot2::geom_label().
Unlike the other geoms the strokes are not geometrically roughened — the
hand-drawn feel comes from the font (see ggsketch_check_fonts() for which
faces are available). If no handwriting font is installed they render with the
device default family.
Usage
geom_sketch_text(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
family = NULL,
nudge_x = 0,
nudge_y = 0,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)
geom_sketch_label(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
family = NULL,
nudge_x = 0,
nudge_y = 0,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE
)Arguments
- mapping
Set of aesthetic mappings created by
ggplot2::aes(). Requires alabelaesthetic.- data
Data to display.
- stat
Statistical transformation (default
"identity").- position
Position adjustment (default
"identity").- ...
Other arguments passed on to
ggplot2::layer(), such assize,colour,angle, orhjust.- family
Font family. By default the first installed handwriting face is used; pass an explicit family to override, or
""for the device default.- nudge_x, nudge_y
Horizontal and vertical adjustment to nudge labels by. Useful for offsetting text from points. Cannot be used together with an explicit
position.- na.rm
If
FALSE(default), missing values are removed with a warning.- show.legend
Logical. Should this layer be included in the legend?
- inherit.aes
If
FALSE, override the default aesthetics.
See also
Other sketch-geoms:
GeomSketchAbline,
GeomSketchBoxplot,
GeomSketchBracket,
GeomSketchCol,
GeomSketchCurve,
GeomSketchEllipse,
GeomSketchHex,
GeomSketchLine,
GeomSketchLinerange,
GeomSketchPath,
GeomSketchPoint,
GeomSketchPolygon,
GeomSketchRect,
GeomSketchRibbon,
GeomSketchRug,
GeomSketchSegment,
GeomSketchSmooth,
GeomSketchSpoke,
GeomSketchViolin,
annotate_sketch(),
geom_sketch_bin2d(),
geom_sketch_contour(),
geom_sketch_count(),
geom_sketch_density(),
geom_sketch_density2d(),
geom_sketch_function(),
geom_sketch_histogram(),
geom_sketch_jitter(),
geom_sketch_qq(),
geom_sketch_quantile()
Examples
library(ggplot2)
df <- data.frame(x = c(1, 2, 3), y = c(2, 3, 1),
lab = c("alpha", "bravo", "charlie"))
# `family = ""` uses the device default, so this runs on any device.
ggplot(df, aes(x, y, label = lab)) +
geom_sketch_text(size = 6, family = "") +
theme_sketch()
# With no `family`, the first installed handwriting font is used. Render with
# a font-capable device (ragg, svglite, cairo) to see it — the base pdf() /
# postscript() devices cannot use unregistered system fonts.
if (FALSE) { # \dontrun{
ggplot(df, aes(x, y, label = lab)) +
geom_sketch_text(size = 6) +
theme_sketch()
} # }
