I am trying to plot a large number of locations that need to be labeled.
Often the locations are quite clustered and the resulting text is
unreadable.  I have been looking through the API and examples on the
matplotlib web page, and I don't see a straightforward way to plot text
labels, preventing them from overlapping.  There is no easy answer to the
problem, since locating the labels so they are close to the point you want
to label, and not overlapping is a sort of optimization problem, I guess.

Using annotate(), the location and alignment of the text can be fixed, but
you don't know the size of the resulting box until after draw() is called.
Once draw is called, you can inquire what the bounding box for a label is,
and then check to see if it overlaps with other labels, but this is an
iterative process, and draw() can be quite slow to call repeatedly.

I guess unless you use a fixed-width font (possible, but not optimal), you
just don't know how big the labels will be, and therefore where they will
extend to, and then how they should be avoided.  This involves coming up
with some sort of accounting system for the location and size of each text
box, outside of the matplotlib API, and seems sub-optimal.

Has anybody dealt with this problem and come up with an elegant or efficient
solution?

Kris
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to