Expand description
Repelling text labels — geom_text_repel / geom_label_repel (R’s
ggrepel).
Labels start at their data point (plus an optional nudge) and are pushed
apart by a deterministic, seeded relaxation until they no longer overlap
each other or the labelled points; a spring pulls each label back towards
its point and every label stays inside the panel. Labels that still overlap
more than max_overlaps other labels/points are dropped (reported as a
render warning, like ggrepel’s “unlabeled data points”). A segment connects
a label to its point when it ended up farther away than
min_segment_length.
The layout runs in pixel space at draw time (text extents depend on the
rendered size), costs O(n log n + overlapping pairs) per iteration thanks to
a sweep over sorted box edges, and is bounded by max_iter and max_time.
Above max_labels labels the simulation is skipped (greedy non-overlapping
placement instead) with a warning.
Structs§
- Geom
Label Repel - Boxed labels repelled away from each other and from their points
(
ggrepel::geom_label_repel). - Geom
Text Repel - Text labels repelled away from each other and from their points
(
ggrepel::geom_text_repel). Requiresx,y,label; an empty /NAlabel is not drawn but its point is still avoided (as in ggrepel). - Repel
Params - Shared layout parameters of
GeomTextRepel/GeomLabelRepel.
Enums§
- Repel
Direction - Axis along which labels may move.