-
Notifications
You must be signed in to change notification settings - Fork 231
Closed
Labels
Description
Describe the issue
fig.canvas.mpl_connect('key_press_event', ...) does not work anymore with matplotlib 3.10. I compiled the following example to demonstrate this (run in a jupyter notebook):
%matplotlib widget
import matplotlib.pyplot as plt
import matplotlib
from ipywidgets import Output
from IPython.display import display
plt.close('test')
fig,ax = plt.subplots(num='test')
output = Output()
def event_handler(event):
with output:
print(event)
fig.canvas.mpl_connect('key_press_event', event_handler)
fig.canvas.mpl_connect('button_release_event', event_handler)
display(output)
When using matplotlib 3.9 the key press event and the mouse button release event cause the event_handler to print the event to the output. After upgrading to matplotlib 3.10, the button_release_event continues to work, but the key_press event does not produce any output anymore. When changing the matplotlib backend to qt (linemagic: "%matplotlib qt") the events work both for matplotlib 3.9 and 3.10
Versions
3.12.8 | packaged by conda-forge | (main, Dec 5 2024, 14:24:40) [GCC 13.3.0]
ipympl version: 0.9.5
Selected Jupyter core packages...
IPython : 8.30.0
ipykernel : 6.29.5
ipywidgets : 8.1.5
jupyter_client : 8.6.3
jupyter_core : 5.7.2
jupyter_server : 2.14.2
jupyterlab : 4.3.4
nbclient : 0.6.8
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : not installed
qtconsole : not installed
traitlets : 5.14.3
Known nbextensions:
config dir: /etc/jupyter/nbconfig
notebook section
jupyter-js-widgets/extension enabled
- Validating: problems found:
- require? X jupyter-js-widgets/extension
JupyterLab v4.3.4
/ssd/opt/miniforge3/envs/dev/share/jupyter/labextensions
jupyter-matplotlib v0.11.5 enabled OK
jupyterlab_pygments v0.3.0 enabled OK (python, jupyterlab_pygments)
jupyter-leaflet v0.19.2 enabled OK
jupyterlab-execute-time v3.2.0 enabled OK (python, jupyterlab_execute_time)
@jupyter-widgets/jupyterlab-manager v5.0.13 enabled OK (python, jupyterlab_widgets)