
Sketchy callouts (boxed labels with a leader arrow)
Source:R/geom-sketch-callout.R
geom_sketch_callout.RdDraws a handwriting label inside a roughened rounded box, optionally with a
hand-drawn leader arrow pointing from the box to a target (xend, yend). The
box auto-sizes to the label, and the leader leaves from the box edge nearest
the target. The sketch take on a speech-bubble / callout annotation.
Usage
GeomSketchCallout
geom_sketch_callout(
mapping = NULL,
data = NULL,
stat = "identity",
position = "identity",
...,
roughness = 1,
bowing = 0.6,
n_passes = 2L,
seed = NULL,
padding = 0.06,
corner_radius = 0.3,
arrow_length = NULL,
arrow_angle = 25,
arrow_head = NULL,
leader = "straight",
curvature = 0.3,
family = NULL,
na.rm = FALSE,
show.legend = FALSE,
inherit.aes = TRUE
)Arguments
- mapping
Aesthetic mappings created by
ggplot2::aes(). Requiresx,y, andlabel; mapxend/yendto add a leader arrow to a target.- data
Data with one row per callout.
- stat
Statistical transformation. Default
"identity".- position
Position adjustment. Default
"identity".- ...
Other arguments passed on to the layer.
- roughness
Non-negative roughness (0 = clean). Default 1.
- bowing
Non-negative bowing multiplier. Default 0.6.
- n_passes
Number of stroke passes. Default 2.
- seed
Integer seed.
NULLusesgetOption("ggsketch.seed", 1L).- padding
Box padding around the label, in inches. Default 0.06.
- corner_radius
Box corner rounding (fraction of half-side). Default 0.3.
- arrow_length
Leader arrowhead length in inches.
NULL(default) adapts it to the leader length.- arrow_angle
Half-angle of the leader arrowhead in degrees. Default 25.
- arrow_head
Leader head style, one of
sketch_arrowheads().NULL(default) draws the open V.- leader
Leader routing:
"straight"(default),"elbow"(horizontal then vertical, flowchart style) or"curved"(a bowed Bezier).- curvature
Bow size when
leader = "curved". Default 0.3.- family
Font family for the label. Defaults to the same family as
theme_sketch()(getOption("ggsketch.base_family", ""), i.e. the device default), so the label matches the plot's other text; setoptions(ggsketch.base_family = "auto")for a handwriting face, or pass an explicit family here.- na.rm
Remove missing values silently? Default
FALSE.- show.legend
Logical; include in legend? Default
FALSE.- inherit.aes
Inherit aesthetics from the plot? Default
TRUE.
Details
For one-off annotations, annotate_sketch_callout() is the easiest entry
point.
See also
Other sketch-geoms:
GeomSketchAbline,
GeomSketchArrow,
GeomSketchBoxplot,
GeomSketchBracket,
GeomSketchChicklet,
GeomSketchCol,
GeomSketchContourFilled,
GeomSketchCurve,
GeomSketchDotplot,
GeomSketchDumbbell,
GeomSketchEdge,
GeomSketchEllipse,
GeomSketchEngrave,
GeomSketchGantt,
GeomSketchHex,
GeomSketchLine,
GeomSketchLinerange,
GeomSketchLollipop,
GeomSketchMarkCircle,
GeomSketchMarkHull,
GeomSketchPath,
GeomSketchPoint,
GeomSketchPolygon,
GeomSketchRect,
GeomSketchRibbon,
GeomSketchRug,
GeomSketchSegment,
GeomSketchSfPolygon,
GeomSketchSlope,
GeomSketchSmooth,
GeomSketchSpoke,
GeomSketchTextRepel,
GeomSketchViolin,
StatSketchBeeswarm,
StatSketchCalendar,
StatSketchDensityRidges,
StatSketchFunnel,
StatSketchPie,
StatSketchPyramid,
StatSketchRadar,
StatSketchStream,
StatSketchTreemap,
StatSketchWaffle,
StatSketchWaterfall,
annotate_sketch(),
annotate_sketch_arrow(),
annotate_sketch_callout(),
annotate_sketch_highlight(),
geom_sketch_alluvial(),
geom_sketch_arc_diagram(),
geom_sketch_bin2d(),
geom_sketch_bump(),
geom_sketch_chord(),
geom_sketch_contour(),
geom_sketch_count(),
geom_sketch_dendrogram(),
geom_sketch_density(),
geom_sketch_density2d(),
geom_sketch_ecdf(),
geom_sketch_function(),
geom_sketch_histogram(),
geom_sketch_jitter(),
geom_sketch_marimekko(),
geom_sketch_mosaic(),
geom_sketch_parallel(),
geom_sketch_qq(),
geom_sketch_quantile(),
geom_sketch_rose(),
geom_sketch_sunburst(),
geom_sketch_text(),
sketch_graph()
Examples
library(ggplot2)
ggplot(mtcars, aes(wt, mpg)) +
geom_sketch_point(seed = 1L) +
annotate_sketch_callout(x = 4, y = 32, label = "outlier?",
xend = 5.25, yend = 18, seed = 2L) +
theme_sketch()