diff --git a/lib/matplotlib/image.py b/lib/matplotlib/image.py index 03b651edafb8..fcffc19e6098 100644 --- a/lib/matplotlib/image.py +++ b/lib/matplotlib/image.py @@ -625,6 +625,13 @@ def contains(self, mouseevent): """ if self._contains is not None: return self._contains(self, mouseevent) + # 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: + return False, {} # TODO: make sure this is consistent with patch and patch # collection on nonlinear transformed coordinates. # TODO: consider returning image coordinates (shouldn't