The above version has some typos (while it works it had some
side-effects), here is the corrected one.
-JJ
import matplotlib.blocking_input as blocking_input
if blocking_input.BlockingMouseInput.add_click ==
blocking_input.BlockingContourLabeler.add_click:
def mouse_event_stop(self, event ):
blocking_input.BlockingInput.pop(self,-1)
self.fig.canvas.stop_event_loop()
def add_click(self, event):
self.button1(event)
def pop_click(self, event, index=-1):
if self.inline:
pass
else:
self.cs.pop_label()
self.cs.ax.figure.canvas.draw()
blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
blocking_input.BlockingContourLabeler.add_click = add_click
blocking_input.BlockingContourLabeler.pop_click = pop_click
On Sat, Feb 6, 2010 at 5:52 PM, David Arnold <[email protected]> wrote:
> JJ,
>
> Very nice repair, as this works precisely as it should. I use this tool in
> Matlab all the time when teaching multivariable calculus.
>
> D.
>
> On Feb 6, 2010, at 2:41 PM, Jae-Joon Lee wrote:
>
>> This is a known bug, and I think I fixed it in the svn. Meanwhile, you
>> may use the monkey patching.
>> Insert these lines in your script (before you call clabel).
>>
>> Regards,
>>
>> -JJ
>>
>>
>> import matplotlib.blocking_input as blocking_input
>> def mouse_event_stop(self, event ):
>> blocking_input.BlockingInput.pop(self,-1)
>> self.fig.canvas.stop_event_loop()
>> def add_click(self, event):
>> self.button1(event)
>> def pop_click(self, event, index=-1):
>> if self.inline:
>> pass
>> else:
>> self.cs.pop_label()
>> self.cs.ax.figure.canvas.draw()
>>
>> blocking_input.BlockingMouseInput.mouse_event_stop = mouse_event_stop
>> blocking_input.BlockingMouseInput.add_click = add_click
>> blocking_input.BlockingMouseInput.pop_click = pop_click
>>
>>
>>
>> On Sat, Feb 6, 2010 at 2:01 AM, David Arnold <[email protected]>
>> wrote:
>>> Hi,
>>>
>>> I'm trying to get manual labeling of contours to work:
>>>
>>> import numpy as np
>>> import matplotlib.mlab as mlab
>>> import matplotlib.pyplot as plt
>>>
>>> delta = 0.025
>>> x = np.arange(-3.0, 3.0, delta)
>>> y = np.arange(-2.0, 2.0, delta)
>>> X, Y = np.meshgrid(x, y)
>>> Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
>>> Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
>>> # difference of Gaussians
>>> Z = 10.0 * (Z2 - Z1)
>>>
>>> plt.figure()
>>> CS = plt.contour(X, Y, Z, 6,
>>> linewidths=np.arange(.5, 4, .5),
>>> colors=('r', 'green', 'blue', (1,1,0), '#afeeee', '0.5')
>>> )
>>> plt.clabel(CS, fontsize=9, inline=1, manual=True)
>>> plt.title('Crazy lines')
>>>
>>> plt.show()
>>>
>>> On my macbook, clicking with the touchpad does not seem to work.
>>>
>>> Any ideas?
>>>
>>> David.
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term contracts
>>> Personal 24x7 support from experience hosting pros just a phone call away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>
>
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users