-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
Milestone
Description
Consider the following code in the notebook:
%pylab notebook
fig, ax = plt.subplots()
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)
these events never print anywhere.
The code does run, as can be seen by this code from @tacaswell:
%pylab notebook
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
collector = []
def onclick(event):
collector.append('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)
After clicking a couple of times:
In [2]: collector
['button=1, x=201, y=275, xdata=2.196853, ydata=0.615071',
'button=1, x=305, y=360, xdata=4.100549, ydata=0.770019',
'button=1, x=421, y=223, xdata=6.205388, ydata=0.520279']
Somehow we're swallowing that stdout completely, I'm not 100% sure why right now. But to the user, it feels very puzzling. Given the equivalent code works just fine at the terminal, we should try to make it work without jumping through additional hoops in the notebook.
xiumingzhang and eldad-a