-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Bug report
Bug summary
Using the first example from the events documentation detects double-click events properly in the Qt backend, but when used in a Jupyter notebook, the two clicks are recognised as two separate single click events.
Code for reproduction
I've adapted the code to show the contents of the event as the figure title instead of a print statement, because the output of print statements inside functions triggered by events disappear in Jupyter notebooks.
import matplotlib.pyplot as plt
import numpy as np
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
def onclick(event):
ax.set_title('%s click: button=%d, x=%d, y=%d, xdata=%f, ydata=%f' %
('double' if event.dblclick else 'single', event.button,
event.x, event.y, event.xdata, event.ydata))
cid = fig.canvas.mpl_connect('button_press_event', onclick)Actual outcome
The title always says single-click, no matter how fast I do my double-clicking.
The double click events are properly captured when using the standard Qt window renderer.
I have tried both the default %matplotlib notebook backend and the ipympl widget backend, and they show identical behaviour.
Matplotlib version
- Operating system: Ubuntu 20.04
- Matplotlib version: 3.2.2
- Matplotlib backend (
print(matplotlib.get_backend())): nbAgg, ipympl - Python version: 3.7.6
- Jupyter version (if applicable): jupyter_client=6.1.6, jupyter_core=4.6.3, notebook=6.0.3
- Other libraries:
Installed in a conda env from conda-forge.
