Skip to content

Commit b72fcde

Browse files
committed
Improve docstring selectors
1 parent 479d9cf commit b72fcde

File tree

1 file changed

+32
-27
lines changed

1 file changed

+32
-27
lines changed

lib/matplotlib/widgets.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,8 +2020,10 @@ def on_select(min: float, max: float) -> Any
20202020
If True, use the backend-dependent blitting features for faster
20212021
canvas updates.
20222022
2023-
rectprops : dict, default: None
2023+
rectprops : dict, optional
20242024
Dictionary of `matplotlib.patches.Patch` properties.
2025+
Default:
2026+
``dict(facecolor='red', alpha=0.5)``
20252027
20262028
onmove_callback : func(min, max), min/max are floats, default: None
20272029
Called on mouse move while the span is being selected.
@@ -2352,8 +2354,11 @@ class ToolLineHandles:
23522354
Positions of handles in data coordinates.
23532355
direction : {"horizontal", "vertical"}
23542356
Direction of handles, either 'vertical' or 'horizontal'
2355-
line_props : dict
2357+
line_props : dict, optional
23562358
Additional line properties. See `matplotlib.lines.Line2D`.
2359+
useblit : bool, default: True
2360+
Whether to use blitting for faster drawing (if supported by the
2361+
backend).
23572362
"""
23582363

23592364
def __init__(self, ax, positions, direction, line_props=None,
@@ -2451,10 +2456,13 @@ class ToolHandles:
24512456
Matplotlib axes where tool handles are displayed.
24522457
x, y : 1D arrays
24532458
Coordinates of control handles.
2454-
marker : str
2459+
marker : str, default: 'o'
24552460
Shape of marker used to display handle. See `matplotlib.pyplot.plot`.
2456-
marker_props : dict
2461+
marker_props : dict, optional
24572462
Additional marker properties. See `matplotlib.lines.Line2D`.
2463+
useblit : bool, default: True
2464+
Whether to use blitting for faster drawing (if supported by the
2465+
backend).
24582466
"""
24592467

24602468
def __init__(self, ax, x, y, marker='o', marker_props=None, useblit=True):
@@ -2515,10 +2523,6 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25152523
where *eclick* and *erelease* are the mouse click and release
25162524
`.MouseEvent`\s that start and complete the selection.
25172525
2518-
drawtype : {"box", "line", "none"}, default: "box"
2519-
Whether to draw the full rectangle box, the diagonal line of the
2520-
rectangle, or nothing at all.
2521-
25222526
minspanx : float, default: 0
25232527
Selections with an x-span less than *minspanx* are ignored.
25242528
@@ -2529,17 +2533,10 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25292533
Whether to use blitting for faster drawing (if supported by the
25302534
backend).
25312535
2532-
lineprops : dict, optional
2533-
Properties with which the line is drawn, if ``drawtype == "line"``.
2534-
Default::
2535-
2536-
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
2537-
25382536
rectprops : dict, optional
2539-
Properties with which the rectangle is drawn, if ``drawtype ==
2540-
"box"``. Default::
2541-
2542-
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
2537+
Properties with which the __ARTIST_NAME__ is drawn.
2538+
Default:
2539+
``dict(facecolor='red', edgecolor='black', alpha=0.2, fill=True))``
25432540
25442541
spancoords : {"data", "pixels"}, default: "data"
25452542
Whether to interpret *minspanx* and *minspany* in data or in pixel
@@ -2552,7 +2549,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25522549
Distance in pixels within which the interactive tool handles can be
25532550
activated.
25542551
2555-
handle_props : dict
2552+
handle_props : dict, optional
25562553
Properties with which the interactive handles are drawn.
25572554
25582555
interactive : bool, default: False
@@ -2577,7 +2574,8 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
25772574
"""
25782575

25792576

2580-
@docstring.Substitution(_RECTANGLESELECTOR_PARAMETERS_DOCSTRING)
2577+
@docstring.Substitution(_RECTANGLESELECTOR_PARAMETERS_DOCSTRING.replace(
2578+
'__ARTIST_NAME__', 'rectangle'))
25812579
class RectangleSelector(_SelectorWidget):
25822580
"""
25832581
Select a rectangular region of an axes.
@@ -2973,7 +2971,8 @@ def geometry(self):
29732971
return np.array(self._to_draw.get_data())
29742972

29752973

2976-
@docstring.Substitution(_RECTANGLESELECTOR_PARAMETERS_DOCSTRING)
2974+
@docstring.Substitution(_RECTANGLESELECTOR_PARAMETERS_DOCSTRING.replace(
2975+
'__ARTIST_NAME__', 'ellipse'))
29772976
class EllipseSelector(RectangleSelector):
29782977
"""
29792978
Select an elliptical region of an axes.
@@ -3075,6 +3074,9 @@ def onselect(verts):
30753074
onselect : function
30763075
Whenever the lasso is released, the *onselect* function is called and
30773076
passed the vertices of the selected path.
3077+
useblit : bool, default: True
3078+
Whether to use blitting for faster drawing (if supported by the
3079+
backend).
30783080
button : `.MouseButton` or list of `.MouseButton`, optional
30793081
The mouse buttons used for rectangle selection. Default is ``None``,
30803082
which corresponds to all buttons.
@@ -3150,17 +3152,17 @@ class PolygonSelector(_SelectorWidget):
31503152
``(xdata, ydata)`` tuples.
31513153
31523154
useblit : bool, default: False
3155+
Whether to use blitting for faster drawing (if supported by the
3156+
backend).
31533157
3154-
lineprops : dict
3158+
lineprops : dict, optional
31553159
Artist properties for the line representing the edges of the polygon.
3156-
Default::
3157-
3160+
Default:
31583161
dict(color='k', linestyle='-', linewidth=2, alpha=0.5)
31593162
3160-
handle_props : dict
3163+
handle_props : dict, optional
31613164
Artist properties for the markers drawn at the vertices of the polygon.
3162-
Default::
3163-
3165+
Default:
31643166
dict(marker='o', markersize=7, mec='k', mfc='k', alpha=0.5)
31653167
31663168
handle_grab_distance : float, default: 15px
@@ -3400,6 +3402,9 @@ class Lasso(AxesWidget):
34003402
The parent axes for the widget.
34013403
xy : (float, float)
34023404
Coordinates of the start of the lasso.
3405+
useblit : bool, default: True
3406+
Whether to use blitting for faster drawing (if supported by the
3407+
backend).
34033408
callback : callable
34043409
Whenever the lasso is released, the *callback* function is called and
34053410
passed the vertices of the selected path.

0 commit comments

Comments
 (0)