On Thu, Aug 21, 2014 at 9:44 AM, Michael Kaufman <[email protected]> wrote:
>
> # plot axvlines here... etc.
>
> global cids
>
> # remove any previous connections
> for i in cids:
> gcf().canvas.mpl_disconnect(i)
> cids = []
>
> cids.append(gcf().canvas.mpl_connect('pick_event',self.pick))
> cids.append(gcf().canvas.mpl_connect('button_press_event',self.click))
>
> draw()
>
> def pick(self, event):
> thisline = event.artist
> xdata, ydata = thisline.get_data()
> print xdata[0]
>
> def click(self, event):
> print "clicked"
See this minimal example
```
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.axvline(.5, picker=6)
ax.plot(range(3))
cids = []
plt.draw()
def pick(event):
thisline = event.artist
xdata, ydata = thisline.get_data()
print xdata[0]
def click(event):
print "clicked"
cids.append(fig.canvas.mpl_connect('pick_event', pick))
cids.append(fig.canvas.mpl_connect('button_press_event', click))
```
If you turn the zoom/pan tool off the picker works again. I suspect
that there is some logic underneath those tools that are snarfing
events when the are turned on to avoid messy conflicts. There is some
work going on (MEP22 iirc) to update the toolbar and make our tool
handling saner.
Tom
--
Thomas Caswell
[email protected]
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users