Thanks to visit codestin.com
Credit goes to github.com

Skip to content

figure_enter_event generates base Event and not LocationEvent #9812

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lkjell opened this issue Nov 19, 2017 · 1 comment
Closed

figure_enter_event generates base Event and not LocationEvent #9812

lkjell opened this issue Nov 19, 2017 · 1 comment
Milestone

Comments

@lkjell
Copy link
Contributor

lkjell commented Nov 19, 2017

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:
@tacaswell tacaswell added this to the v2.2 milestone Nov 19, 2017
efiring added a commit that referenced this issue Mar 5, 2018
figure_enter_event uses now LocationEvent instead of Event. Fix issue #9812.
@efiring
Copy link
Member

efiring commented Mar 5, 2018

Closed by #9814

@efiring efiring closed this as completed Mar 5, 2018
@QuLogic QuLogic modified the milestones: needs sorting, v3.0 Mar 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants