cphyc / matplotlib-label-lines

Label line using matplotlib.
MIT License
301 stars 28 forks source link

Implement heuristic to place labels. #59

Closed cphyc closed 3 years ago

cphyc commented 3 years ago

This implements a new heuristic to place labels that works as follow:

  1. We find the extent of the data and of the plot
  2. We generate equally spaced positions in between
  3. If the first line to be annotated contains the first position, the second line the second position, ... then we're done
  4. Otherwise, we mix and match the label positions with the lines to maximise the number of lines that contain a position. For the remaining ones, we simply put the label on the line wherever we find a spot.

This fixes #58.