diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index a41428a5f345..e8ddf2613ec2 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -597,7 +597,9 @@ def contains(self, mouseevent): # collection on nonlinear transformed coordinates. # TODO: consider returning image coordinates (shouldn't # be too difficult given that the image is rectilinear - x, y = mouseevent.xdata, mouseevent.ydata + trans = self.get_transform() + x, y = trans.inverted().transform((mouseevent.x, mouseevent.y)) + xmin, xmax, ymin, ymax = self.get_extent() if xmin > xmax: xmin, xmax = xmax, xmin