plot icon indicating copy to clipboard operation
plot copied to clipboard

Repulsive labels

Open allisonhorst opened this issue 3 years ago • 4 comments

For charts with dense or overlapping labels, it would be useful to have a way to create repulsive labels to avoid overlap (similar to ggrepel for ggplot2).

allisonhorst avatar Dec 05 '22 17:12 allisonhorst

This might be needing an algorithm similar to Dorling cartograms, for example with a force simulation.

Among the notable differences/or features that we might want to support:

  • labels are closer to rects (or ellipses) rather than circles (ellipses can be achieved by upscaling y)
  • we prefer if label avoid occluding features of the map
  • sometimes we prefer if the labels are somehow "aligned" with the points of interest
  • sometimes if the label is small and the point is large, we will place it at the center; other times, connect it with a line to the point of interest.

Fil avatar Dec 06 '22 11:12 Fil

Probably already covered by #27, but we could leave this open if there’s specifically demand for this type of labeling algorithm.

mbostock avatar Dec 07 '22 18:12 mbostock

Or use a voronoi initializer transform: https://observablehq.com/@fil/plot-voronoi-labels

Fil avatar Dec 08 '22 15:12 Fil

Ref. https://www.andrewheiss.com/blog/2023/06/01/geocoding-routing-openstreetmap-r/

mbostock avatar Jun 02 '23 16:06 mbostock