8000 FIX: Ensuring both x and y attrs of LocationEvent are int by TarasKuzyo · Pull Request #11530 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

FIX: Ensuring both x and y attrs of LocationEvent are int #11530

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

Merged
merged 7 commits into from
Jul 1, 2018
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions lib/matplotlib/backend_bases.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -1342,10 +1342,10 @@ class LocationEvent(Event):

Attributes
----------
x : scalar
x : int
x position - pixels from left of canvas

y : scalar
y : int
y position - pixels from bottom of canvas

inaxes : bool
Expand All @@ -1365,8 +1365,10 @@ def __init__(self, name, canvas, x, y, guiEvent=None):
*x*, *y* in figure coords, 0,0 = bottom, left
"""
Event.__init__(self, name, canvas, guiEvent=guiEvent)
self.x = x # x position - pixels from left of canvas
self.y = y # y position - pixels from right of canvas
# x position - pixels from left of canvas
self.x = int(x) if x is not None else 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably leave the current behavior of x and y being allowed to be None. I am not sure why that is allowed, but we should not change it!

# y position - pixels from right of canvas
self.y = int(y) if y is not None else 0
self.inaxes = None # the Axes instance if mouse us over axes
self.xdata = None # x coord of mouse in data coords
self.ydata = None # y coord of mouse in data coords
Expand Down
0