canvas.mpl_connect in jupyter notebook : <p>I have the following code in test.py:</p>

<pre><code>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)
</code></pre>

<p>when i run test.py in the command line by "python test.py", 'button=%d, x=%d, y=%d, xdata=%f, ydata=%f' gets printed as i click the plot</p>

<p>however, the results are not printed in jupyter notebook.</p>

<p>how to fix it?</p>

<p>thanks in advance!</p>
