0

I am new to python, and I am trying to implement a scrolling function to flip through a set of images quickly using keyboard keys.

I tried first to run the example code for the Matplotlib Documentation:

`

fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(np.random.rand(10))

def onclick(event):
    print('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)

`

But when I run it, the "onclick" features do not work.

I am trying to run this in a jupyter notebook using python 3, on a Linux distribution.

There is probably a simple reason behind the fact that it's not working, but I can't figure it out...

Many thanks in advance, Best wishes, Camille.

  • I don't think event handling works in a jupyter notebooks. Try it in a standalone python interpreter and see if that works? – Diziet Asahi Oct 05 '17 at 18:06
  • Apart from [duplicate](https://stackoverflow.com/questions/46263056/cant-print-the-text-on-jupyter-notebook-using-matplotlib-pyplot), also see [this question](https://stackoverflow.com/questions/43923313/canvas-mpl-connect-in-jupyter-notebook). [This one](https://stackoverflow.com/questions/44195042/looping-over-clickable-plot-in-python) might be of help for the actual feature. – ImportanceOfBeingErnest Oct 06 '17 at 11:27

0 Answers0