Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simplify outdated Image.contains check.#25558

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
greglucas merged 1 commit intomatplotlib:mainfromanntzer:ic
Jul 16, 2023
Merged
Changes fromall 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
24 changes: 6 additions & 18 deletionslib/matplotlib/image.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -654,14 +654,9 @@ def draw(self, renderer, *args, **kwargs):

def contains(self, mouseevent):
"""Test whether the mouse event occurred within the image."""
if self._different_canvas(mouseevent):
return False, {}
# 1) This doesn't work for figimage; but figimage also needs a fix
# below (as the check cannot use x/ydata and extents).
# 2) As long as the check below uses x/ydata, we need to test axes
# identity instead of `self.axes.contains(event)` because even if
# axes overlap, x/ydata is only valid for event.inaxes anyways.
if self.axes is not mouseevent.inaxes:
if (self._different_canvas(mouseevent)
# This doesn't work for figimage.
or not self.axes.contains(mouseevent)[0]):
return False, {}
# TODO: make sure this is consistent with patch and patch
# collection on nonlinear transformed coordinates.
Expand All@@ -670,16 +665,9 @@ def contains(self, mouseevent):
trans = self.get_transform().inverted()
x, y = trans.transform([mouseevent.x, mouseevent.y])
xmin, xmax, ymin, ymax = self.get_extent()
if xmin > xmax:
xmin, xmax = xmax, xmin
if ymin > ymax:
ymin, ymax = ymax, ymin

if x is not None and y is not None:
inside = (xmin <= x <= xmax) and (ymin <= y <= ymax)
else:
inside = False

# This checks xmin <= x <= xmax *or* xmax <= x <= xmin.
inside = (x is not None and (x - xmin) * (x - xmax) <= 0
and y is not None and (y - ymin) * (y - ymax) <= 0)
return inside, {}

def write_png(self, fname):
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp