Hi,
Attached is a patch (created by issuing svn diff from the
matplotlib/trunk/matplotlib directory) for adding the capability to
manually select the location of contour labels in clabel. Though the
existing algorithm for automatically placing contour labels is very
good, for complex figures with multiple elements it is often desirable
to manually place labels. This functionality is meant to imitate the
matlab functionality of clabel(cs,'manual').
The attached patch includes a modified version of the changes I
previously made to add a "waitforbuttonpress" command to matplotlib as
these changes are a prerequisite for using the added functionality of
clabel (i.e., you shouldn't apply both patches, just this last one).
The changes work as follows:
cs = contour(x,y,z)
cl = clabel(cs,'manual')
(use the third mouse button to finish placing labels, second button to
erase a previously added label)
The patch isn't done - manually selected labels won't be rotated or
inline. There is also a need for general cleaning up and documentation.
I just want to see what people think about the approach before investing
more time. I added this functionality by adding a class
ContourLabelerWithManual that inherits from ContourLabeler and
BlockingMouseInput (the class used by ginput to interactively select
points). ContourSet then inherits from ContourLabelerWithManual instead
of ContourLabeler. If manual is selected, then it enters interactive
mode, if not, then results should be as before.
I also had to move the classes Blocking*Input from figure.py to a
separate file blocking_input.py to avoid circular imports.
Please let me know what you think. Also, I am wondering if the powers
that be would be willing to give me commit access to my own branch of
the matplotlib svn. I don't want to modify the trunk, but for my own
sanity, it would be nice to be able to keep track of my changes
somewhere. If not, I would like to here what other non-commit
developers do to best organize changes.
Thanks,
David
waitforbuttonpress_and_clabel.patch (17.8 KB)
···
--
**********************************
David M. Kaplan
Assistant Researcher
UCSC / Institute of Marine Sciences
Ocean Sciences
1156 High St.
SC, CA 95064
Phone: 831-459-4789
Fax: 831-459-4882
http://pmc.ucsc.edu/~dmk/
**********************************