On Sat, Feb 27, 2016 at 1:18 PM, Andy Davidson <
a...@santacruzintegration.com> wrote:

> Thanks. %matplitlib notebook looks great!. As I move the mouse around I
> see values for x, and y . Any idea how I can get programmatic access to the
> mouse events? I.E. When a user clicks I need to fetch some additional info.
>
> I am sure there are many other things I’ll eventually want to do. For
> example I have several different lines on the same graph. I want to make it
> easy for the user to select values on a give line not just some random spot
>
> Are there any other code examples or documentation?
>

Unfortunately it doesn't work perfectly yet, see:

https://github.com/jupyter/notebook/issues/244
https://github.com/matplotlib/matplotlib/issues/4582

But the following code can be used as a workaround, using an IPython widget
to display the event data:

```
%pylab notebook
import ipywidgets as widgets

fig, ax = plt.subplots()
ax.plot(np.random.rand(10))

w = widgets.HTML()

def onclick(event):
    w.value = 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f'%(
              event.button, event.x, event.y, event.xdata, event.ydata)

cid = fig.canvas.mpl_connect('button_press_event', onclick)
display(w)
```

Note, however, that at least for me, the interactive figures in the
notebook are getting auto-closed for reasons I don't understand:
https://github.com/matplotlib/matplotlib/issues/6075.

Cheers,

-- 
Fernando Perez (@fperez_org; http://fperez.org)
fperez.net-at-gmail: mailing lists only (I ignore this when swamped!)
fernando.perez-at-berkeley: contact me here for any direct mail
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to