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

Appearance settings

Commit 4b1e79f

Browse filesBrowse files
authored
Document Artist.get_cursor_data (#12427)
1 parent 1c17868 commit 4b1e79f
Copy full SHA for 4b1e79f

File tree

Expand file treeCollapse file tree

2 files changed

+44
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+44
-4
lines changed

‎lib/matplotlib/artist.py

Copy file name to clipboardExpand all lines: lib/matplotlib/artist.py
+35-2Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,13 +1114,46 @@ def matchfunc(x):
11141114

11151115
def get_cursor_data(self, event):
11161116
"""
1117-
Get the cursor data for a given event.
1117+
Return the cursor data for a given event.
1118+
1119+
.. note::
1120+
This method is intended to be overridden by artist subclasses
1121+
(or monkeypatched). As an end-user of Matplotlib you will most
1122+
likely not call this method yourself.
1123+
1124+
Cursor data can be used by Artists to provide additional context
1125+
information for a given event. The default implementation just returns
1126+
*None*.
1127+
1128+
Subclasses can override the method and return arbitrary data. However,
1129+
when doing so, they must ensure that `.format_cursor_data` can convert
1130+
the data to a string representation.
1131+
1132+
The only current use case is displaying the z-value of an `.AxesImage`
1133+
in the status bar of a plot window, while moving the mouse.
1134+
1135+
See Also
1136+
--------
1137+
format_cursor_data
1138+
11181139
"""
11191140
return None
11201141

11211142
def format_cursor_data(self, data):
11221143
"""
1123-
Return *cursor data* string formatted.
1144+
Return a string representation of *data*.
1145+
1146+
.. note::
1147+
This method is intended to be overridden by artist subclasses
1148+
(or monkeypatched). As an end-user of Matplotlib you will most
1149+
likely not call this method yourself.
1150+
1151+
The default implementation converts ints and floats and arrays of ints
1152+
and floats into a comma-separated string enclosed in square brackets.
1153+
1154+
See Also
1155+
--------
1156+
get_cursor_data
11241157
"""
11251158
try:
11261159
data[0]

‎lib/matplotlib/image.py

Copy file name to clipboardExpand all lines: lib/matplotlib/image.py
+9-2Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,14 @@ def get_extent(self):
881881
return (-0.5, numcols-0.5, -0.5, numrows-0.5)
882882

883883
def get_cursor_data(self, event):
884-
"""Get the cursor data for a given event"""
884+
"""
885+
Return the image value at the event position or *None* if the event is
886+
outside the image.
887+
888+
See Also
889+
--------
890+
matplotlib.artist.Artist.get_cursor_data
891+
"""
885892
xmin, xmax, ymin, ymax = self.get_extent()
886893
if self.origin == 'upper':
887894
ymin, ymax = ymax, ymin
@@ -1142,7 +1149,7 @@ def set_array(self, *args):
11421149
raise NotImplementedError('Method not supported')
11431150

11441151
def get_cursor_data(self, event):
1145-
"""Get the cursor data for a given event"""
1152+
# docstring inherited
11461153
x, y = event.xdata, event.ydata
11471154
if (x < self._Ax[0] or x > self._Ax[-1] or
11481155
y < self._Ay[0] or y > self._Ay[-1]):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.