-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Bug report
Bug summary
As of matplotlib version 3.3.2, calling IPython.display.clear_output() in a jupyter notebook seems to break the matplotlib figure event handler system. It seems to be a problem with the interaction between the jupyter notebook widget display system and the matplotlib event system, but reverting to matplotlib 3.3.1 corrects the issue.
Code for reproduction
In a jupyter notebook:
# Paste your code here
%matplotlib notebook
from matplotlib import pyplot as plt
import IPython
import ipywidgets as wdg
wOut = wdg.Output()
def onClick(event):
with wOut:
IPython.display.clear_output()
print(event)
fig, ax = plt.subplots(1,1)
eventid = fig.canvas.mpl_connect('button_press_event', onClick)
IPython.display.display(wOut)Actual outcome
Clicking on the plot once updates the text in the Output widget, further clicks do nothing.
Further events result in error messages from the jupyter server:
# If applicable, paste the console output here
[IPKernelApp] WARNING | No such comm: 565a2c88b5ff42b08d89aa4cecd34763
Expected outcome
Each time you click on the plot the text in the Output widget should be updated with details of the event.
This code works in version 3.3.1, but not in 3.3.2.
- Operating system: Ubuntu
- Matplotlib version: 3.3.2
- Matplotlib backend (
print(matplotlib.get_backend())): nbAgg - Python version: 3.7.9
- Jupyter version (if applicable): 6.1.4
- Other libraries: IPython 7.19.0
conda
default channel