Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
Bug report
Bug summary
I'm implementing live plotting for our data acquisition system using Jupyter and FuncAnimation, and have just found an interesting defect inplt.show(block=True)
behaviour.
Precisely, it does not unblock when the plot window is closed, and sending KeyboardInterrupt crashes the kernel.
I was able to accidentally fix the first part by modifying theshow()
function inbackend_bases.py
based onthis forum reply (basically, by not callingmanager.canvas.figure.show()
when block is not None, and instead callingmanager.window.setVisible(True)
just beforecls.mainloop()
since it calls Qt'sexec()
that should callshow()
by itself)
The second issue persists, though.
Code for reproduction
%pylabqt5importnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlib.animationimportFuncAnimationfig,ax=plt.subplots()xdata,ydata= [], []ln,=plt.plot([], [],'ro')definit():ax.set_xlim(0,2*np.pi)ax.set_ylim(-1,1)returnln,defupdate(frame):xdata.append(frame)ydata.append(np.sin(frame))ln.set_data(xdata,ydata)returnln,ani=FuncAnimation(fig,update,frames=np.linspace(0,2*np.pi,128),init_func=init,blit=True,interval=50)plt.show(block=True)
Actual outcome
Plot window that can be closed by either pressing the corresponding window button or by sending KeyboardInterrupt. The kernel then should be freed.
Expected outcome
The kernel is not freed upon closing (without my fix) and dies on KeyboardInterrupt.
Matplotlib version
- Operating system: 4.18.16-100.fc27.x86_64
- Matplotlib version: 3.0.2
- Matplotlib backend: Qt5Agg
- Python version: 3.6
- IPython: 7.2.0
- Jupyter notebook: 5.7.4
Everything installed with pip in a virtualenv.