Skip to content
Closed
Changes from all 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
14 changes: 13 additions & 1 deletion lib/matplotlib/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@ def format_cursor_data(self, data):


class NonUniformImage(AxesImage):
mouseover = False # This class still needs its own get_cursor_data impl.

def __init__(self, ax, *, interpolation='nearest', **kwargs):
"""
Expand Down Expand Up @@ -1132,6 +1131,19 @@ def set_cmap(self, cmap):
raise RuntimeError('Cannot change colors after loading data')
super().set_cmap(cmap)

def get_cursor_data(self, event):
# docstring inherited
x, y = event.xdata, event.ydata
if (x < self._Ax[0] or x > self._Ax[-1] or
y < self._Ay[0] or y > self._Ay[-1]):
return None
j = np.searchsorted(self._Ax, x) - 1
i = np.searchsorted(self._Ay, y) - 1
try:
return self._A[i, j]
except IndexError:
return None


class PcolorImage(AxesImage):
"""
Expand Down