
Repel overlapping label boxes away from each other and their anchors
Source:R/core-repel.R
repel_layout.RdA small physical solver behind geom_sketch_text_repel() /
geom_sketch_label_repel(). Each label starts near its anchor and is pushed
by three forces, iterated to rest: boxes that overlap shove each other apart
along their axis of least penetration (preferring an axis with room left
inside the bounds, so pairs pressed into a panel corner escape along the
edge instead of staying stuck); a box covering any anchor point slides
off it; and a weak spring pulls each box back toward its own anchor so labels
stay close to what they name. Positions are clamped to xlim / ylim.
Arguments
- ax, ay
Anchor points (one per label), in a single isotropic space (e.g. device inches).
- w, h
Label box width and height (same units), recycled to the anchors.
- xlim, ylim
Length-2 bounds the box centres are kept within.
- box_padding, point_padding
Extra clearance around boxes and around anchor points, in the same units.
- max_iter
Maximum solver iterations. Default 2000.
- seed
Integer seed (for the tiny start jitter that separates labels sharing an anchor).
See also
Other sketch-core:
arrowhead(),
curve_fill(),
engrave_fill(),
engrave_ladder(),
hachure_fill(),
hachure_fill_multi(),
leader_path(),
rough_arc(),
rough_bezier(),
rough_ellipse(),
roughen_polyline(),
sketch_arrowheads(),
sketch_fill(),
sketch_fill_multi(),
spray_scatter(),
stroke_profile(),
stroke_ribbon(),
treemap_layout(),
wash_bleed(),
watercolor_wash(),
watercolor_wash_multi()