Closed
Description
Bug report
Bug summary
In the documentation [1] it says that "figure_enter_event" generates a LocationEvent. However in the source code it just generates the base class Event.
Further investigation showed that some backends do not pass their coordinates when entering the figure. The tkagg backend (default) does not have figure_enter_event nor figure_leave_event.
grep "FigureCanvasBase.enter_notify_event" *py
backend_gtk3.py: FigureCanvasBase.enter_notify_event(self, event)
backend_gtk.py: FigureCanvasBase.enter_notify_event(self, event, xy=(x, y))
backend_qt5.py: FigureCanvasBase.enter_notify_event(self, guiEvent=event)
backend_wx.py: FigureCanvasBase.enter_notify_event(self, guiEvent=evt)
[1] : https://matplotlib.org/users/event_handling.html
Code for reproduction
import matplotlib
matplotlib.use("Qt5Agg") #may omit
import matplotlib.pyplot as plt
import numpy as np
x = range(100)
fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
def stat(event):
print("axes: {}, x: {}, y: {}".format(event.inaxes, event.x, event.y))
cid = fig.canvas.mpl_connect('figure_enter_event', stat)
cid = fig.canvas.mpl_connect('figure_leave_event', stat)
plt.show()
Actual outcome
Missing LocationEvent attributes.
Expected outcome
Expect LocationEvent attributes and the documentation to be consistent
Matplotlib version
- Operating system:
- Matplotlib version: 2.1.0, 2.0.2
- Matplotlib backend (
print(matplotlib.get_backend())
): - Python version: 3.5
- Jupyter version (if applicable):
- Other libraries:
Metadata
Metadata
Assignees
Labels
No labels