@@ -1257,28 +1257,34 @@ def funchspace(self, val):
1257
1257
1258
1258
class Cursor (AxesWidget ):
1259
1259
"""
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.
1263
1261
1264
- *horizOn*
1265
- Controls the visibility of the horizontal line
1262
+ For the cursor to remain responsive you must keep a reference to it.
1266
1263
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`.
1271
1280
1272
- For the cursor to remain responsive you must keep a reference to
1273
- it.
1281
+ Examples
1282
+ --------
1283
+ See :doc:`/gallery/widgets/cursor`.
1274
1284
"""
1285
+
1275
1286
def __init__ (self , ax , horizOn = True , vertOn = True , useblit = False ,
1276
1287
** 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
- """
1282
1288
AxesWidget .__init__ (self , ax )
1283
1289
1284
1290
self .connect_event ('motion_notify_event' , self .onmove )
@@ -1298,7 +1304,7 @@ def __init__(self, ax, horizOn=True, vertOn=True, useblit=False,
1298
1304
self .needclear = False
1299
1305
1300
1306
def clear (self , event ):
1301
- """clear the cursor"""
1307
+ """Internal event handler to clear the cursor. """
1302
1308
if self .ignore (event ):
1303
1309
return
1304
1310
if self .useblit :
@@ -1307,7 +1313,7 @@ def clear(self, event):
1307
1313
self .lineh .set_visible (False )
1308
1314
1309
1315
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. """
1311
1317
if self .ignore (event ):
1312
1318
return
1313
1319
if not self .canvas .widgetlock .available (self ):
@@ -1332,17 +1338,14 @@ def onmove(self, event):
1332
1338
self ._update ()
1333
1339
1334
1340
def _update (self ):
1335
-
1336
1341
if self .useblit :
1337
1342
if self .background is not None :
1338
1343
self .canvas .restore_region (self .background )
1339
1344
self .ax .draw_artist (self .linev )
1340
1345
self .ax .draw_artist (self .lineh )
1341
1346
self .canvas .blit (self .ax .bbox )
1342
1347
else :
1343
-
1344
1348
self .canvas .draw_idle ()
1345
-
1346
1349
return False
1347
1350
1348
1351
0 commit comments