Skip to content

Commit 0583079

Browse files
authored
Merge pull request #12959 from timhoffm/doc-cursor
Update the documentation of Cursor
2 parents 0fec7f1 + 188bd8a commit 0583079

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

lib/matplotlib/widgets.py

+24-21
Original file line numberDiff line numberDiff line change
@@ -1257,28 +1257,34 @@ def funchspace(self, val):
12571257

12581258
class Cursor(AxesWidget):
12591259
"""
1260-
A horizontal and vertical line that spans the axes and moves with
1261-
the pointer. You can turn off the hline or vline respectively with
1262-
the following attributes:
1260+
A crosshair cursor that spans the axes and moves with mouse cursor.
12631261
1264-
*horizOn*
1265-
Controls the visibility of the horizontal line
1262+
For the cursor to remain responsive you must keep a reference to it.
12661263
1267-
*vertOn*
1268-
Controls the visibility of the horizontal line
1269-
1270-
and the visibility of the cursor itself with the *visible* attribute.
1264+
Parameters
1265+
----------
1266+
ax : `matplotlib.axes.Axes`
1267+
The `~.axes.Axes` to attach the cursor to.
1268+
horizOn : bool, optional, default: True
1269+
Whether to draw the horizontal line.
1270+
vertOn : bool, optional, default: True
1271+
Whether to draw the vertical line.
1272+
useblit : bool, optional, default: False
1273+
Use blitting for faster drawing if supported by the backend.
1274+
1275+
Other Parameters
1276+
----------------
1277+
**lineprops
1278+
`.Line2D` porperties that control the appearance of the lines.
1279+
See also `~.Axes.axhline`.
12711280
1272-
For the cursor to remain responsive you must keep a reference to
1273-
it.
1281+
Examples
1282+
--------
1283+
See :doc:`/gallery/widgets/cursor`.
12741284
"""
1285+
12751286
def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
12761287
**lineprops):
1277-
"""
1278-
Add a cursor to *ax*. If ``useblit=True``, use the backend-dependent
1279-
blitting features for faster updates. *lineprops* is a dictionary of
1280-
line properties.
1281-
"""
12821288
AxesWidget.__init__(self, ax)
12831289

12841290
self.connect_event('motion_notify_event', self.onmove)
@@ -1298,7 +1304,7 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
12981304
self.needclear = False
12991305

13001306
def clear(self, event):
1301-
"""clear the cursor"""
1307+
"""Internal event handler to clear the cursor."""
13021308
if self.ignore(event):
13031309
return
13041310
if self.useblit:
@@ -1307,7 +1313,7 @@ def clear(self, event):
13071313
self.lineh.set_visible(False)
13081314

13091315
def onmove(self, event):
1310-
"""on mouse motion draw the cursor if visible"""
1316+
"""Internal event handler to draw the cursor when the mouse moves."""
13111317
if self.ignore(event):
13121318
return
13131319
if not self.canvas.widgetlock.available(self):
@@ -1332,17 +1338,14 @@ def onmove(self, event):
13321338
self._update()
13331339

13341340
def _update(self):
1335-
13361341
if self.useblit:
13371342
if self.background is not None:
13381343
self.canvas.restore_region(self.background)
13391344
self.ax.draw_artist(self.linev)
13401345
self.ax.draw_artist(self.lineh)
13411346
self.canvas.blit(self.ax.bbox)
13421347
else:
1343-
13441348
self.canvas.draw_idle()
1345-
13461349
return False
13471350

13481351

0 commit comments

Comments
 (0)