Resolves overlapping text labels using a two-phase algorithm: (1) push overlapping labels apart symmetrically, (2) spring-pull labels back toward their anchors without reintroducing overlaps.
repel_text(
x,
y,
widths,
heights,
anchor_x = x,
anchor_y = y,
min_gap = 0,
iterations = 20,
axis = "both"
)A list with elements x and y giving adjusted positions.
Numeric vectors of current label positions.
Numeric vectors of label bounding box dimensions (in
the same units as x and y).
Numeric vectors of original target positions that
labels are pulled back toward during the spring pass. Defaults to x
and y.
Minimum padding between labels. Default 0.
Maximum number of repulsion iterations. Default 20.
Movement constraint: "both" (default), "x", or "y".