No, there is no way built into matplotlib to do that. You are supposed to either live with the default locations or go fully interactive with manual and using the mouse.
You might want to file this as a bug report upstream so they can improve their algorithms.
There are multiple options to work around this. The first one is to programmatically place text on the contour figure. You will not be able to reliably remove the lines underneath the text this way. Assuming you have a contour c
you can find the contour lines in c.collections
. For every contour line invoke get_paths
and place your text on that path.
The other option would be to replace the code for manual placement (in matplotlib.contour.BlockingContourLabeler
) or tweak the code that finds the label positions (in matplotlib.contour.locate_label
), but both functions are pretty dense. If you can come up with a working replacement for locate_label
just overwrite the old method in your plotting macro
def your_locate_label(self, linecontour, labelwidth):
# some magic
pass
ar = np.array([[1,0], [0,1]]
c = matplotlib.contour(ar)
c.locate_label = your_locate_label
c.clabel()
Btw, if you use ipython
you can easily view the function source from your interactive session with
%psource c.clabel
or directly invoke your $EDITOR
on the file were it is defined with
%edit c.clabel