Skip to content

Commit f1d7ac8

Browse files
committed
Move RectangleSelector from __init__ to class docstring.
1 parent e093d88 commit f1d7ac8

File tree

1 file changed

+70
-71
lines changed

1 file changed

+70
-71
lines changed

lib/matplotlib/widgets.py

Lines changed: 70 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -2499,103 +2499,102 @@ def closest(self, x, y):
24992499

25002500

25012501
class RectangleSelector(_SelectorWidget):
2502-
"""
2502+
r"""
25032503
Select a rectangular region of an axes.
25042504
25052505
For the cursor to remain responsive you must keep a reference to it.
25062506
2507-
Examples
2508-
--------
2509-
:doc:`/gallery/widgets/rectangle_selector`
2510-
"""
2507+
Parameters
2508+
----------
2509+
ax : `~matplotlib.axes.Axes`
2510+
The parent axes for the widget.
25112511
2512-
_shape_klass = Rectangle
2512+
onselect : function
2513+
A callback function that is called after a selection is completed.
2514+
It must have the signature::
25132515
2514-
@_api.rename_parameter("3.5", "maxdist", "handle_grab_distance")
2515-
@_api.rename_parameter("3.5", "marker_props", "handle_props")
2516-
@_api.delete_parameter("3.5", "drawtype")
2517-
@_api.delete_parameter("3.5", "lineprops")
2518-
def __init__(self, ax, onselect, drawtype='box',
2519-
minspanx=0, minspany=0, useblit=False,
2520-
lineprops=None, rectprops=None, spancoords='data',
2521-
button=None, handle_grab_distance=10, handle_props=None,
2522-
interactive=False, state_modifier_keys=None,
2523-
drag_from_anywhere=False):
2524-
r"""
2525-
Parameters
2526-
----------
2527-
ax : `~matplotlib.axes.Axes`
2528-
The parent axes for the widget.
2516+
def onselect(eclick: MouseEvent, erelease: MouseEvent)
25292517
2530-
onselect : function
2531-
A callback function that is called after a selection is completed.
2532-
It must have the signature::
2518+
where *eclick* and *erelease* are the mouse click and release
2519+
`.MouseEvent`\s that start and complete the selection.
25332520
2534-
def onselect(eclick: MouseEvent, erelease: MouseEvent)
2521+
drawtype : {"box", "line", "none"}, default: "box"
2522+
Whether to draw the full rectangle box, the diagonal line of the
2523+
rectangle, or nothing at all.
25352524
2536-
where *eclick* and *erelease* are the mouse click and release
2537-
`.MouseEvent`\s that start and complete the selection.
2525+
minspanx : float, default: 0
2526+
Selections with an x-span less than *minspanx* are ignored.
25382527
2539-
drawtype : {"box", "line", "none"}, default: "box"
2540-
Whether to draw the full rectangle box, the diagonal line of the
2541-
rectangle, or nothing at all.
2528+
minspany : float, default: 0
2529+
Selections with an y-span less than *minspany* are ignored.
25422530
2543-
minspanx : float, default: 0
2544-
Selections with an x-span less than *minspanx* are ignored.
2531+
useblit : bool, default: False
2532+
Whether to use blitting for faster drawing (if supported by the
2533+
backend).
25452534
2546-
minspany : float, default: 0
2547-
Selections with an y-span less than *minspany* are ignored.
2535+
lineprops : dict, optional
2536+
Properties with which the line is drawn, if ``drawtype == "line"``.
2537+
Default::
25482538
2549-
useblit : bool, default: False
2550-
Whether to use blitting for faster drawing (if supported by the
2551-
backend).
2539+
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
25522540
2553-
lineprops : dict, optional
2554-
Properties with which the line is drawn, if ``drawtype == "line"``.
2555-
Default::
2541+
rectprops : dict, optional
2542+
Properties with which the rectangle is drawn, if ``drawtype ==
2543+
"box"``. Default::
25562544
2557-
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
2545+
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
25582546
2559-
rectprops : dict, optional
2560-
Properties with which the rectangle is drawn, if ``drawtype ==
2561-
"box"``. Default::
2547+
spancoords : {"data", "pixels"}, default: "data"
2548+
Whether to interpret *minspanx* and *minspany* in data or in pixel
2549+
coordinates.
25622550
2563-
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
2551+
button : `.MouseButton`, list of `.MouseButton`, default: all buttons
2552+
Button(s) that trigger rectangle selection.
25642553
2565-
spancoords : {"data", "pixels"}, default: "data"
2566-
Whether to interpret *minspanx* and *minspany* in data or in pixel
2567-
coordinates.
2554+
handle_grab_distance : float, default: 10
2555+
Distance in pixels within which the interactive tool handles can be
2556+
activated.
25682557
2569-
button : `.MouseButton`, list of `.MouseButton`, default: all buttons
2570-
Button(s) that trigger rectangle selection.
2558+
handle_props : dict
2559+
Properties with which the interactive handles are drawn.
25712560
2572-
handle_grab_distance : float, default: 10
2573-
Distance in pixels within which the interactive tool handles can be
2574-
activated.
2561+
interactive : bool, default: False
2562+
Whether to draw a set of handles that allow interaction with the
2563+
widget after it is drawn.
25752564
2576-
handle_props : dict
2577-
Properties with which the interactive handles are drawn.
2565+
state_modifier_keys : dict, optional
2566+
Keyboard modifiers which affect the widget's behavior. Values
2567+
amend the defaults.
25782568
2579-
interactive : bool, default: False
2580-
Whether to draw a set of handles that allow interaction with the
2581-
widget after it is drawn.
2569+
- "move": Move the existing shape, default: no modifier.
2570+
- "clear": Clear the current shape, default: "escape".
2571+
- "square": Makes the shape square, default: "shift".
2572+
- "center": Make the initial point the center of the shape,
2573+
default: "ctrl".
25822574
2583-
state_modifier_keys : dict, optional
2584-
Keyboard modifiers which affect the widget's behavior. Values
2585-
amend the defaults.
2575+
"square" and "center" can be combined.
25862576
2587-
- "move": Move the existing shape, default: no modifier.
2588-
- "clear": Clear the current shape, default: "escape".
2589-
- "square": Makes the shape square, default: "shift".
2590-
- "center": Make the initial point the center of the shape,
2591-
default: "ctrl".
2577+
drag_from_anywhere : bool, optional
2578+
If `True`, the widget can be moved by clicking anywhere within
2579+
its bounds.
25922580
2593-
"square" and "center" can be combined.
2581+
Examples
2582+
--------
2583+
:doc:`/gallery/widgets/rectangle_selector`
2584+
"""
25942585

2595-
drag_from_anywhere : bool, optional
2596-
If `True`, the widget can be moved by clicking anywhere within
2597-
its bounds.
2598-
"""
2586+
_shape_klass = Rectangle
2587+
2588+
@_api.rename_parameter("3.5", "maxdist", "handle_grab_distance")
2589+
@_api.rename_parameter("3.5", "marker_props", "handle_props")
2590+
@_api.delete_parameter("3.5", "drawtype")
2591+
@_api.delete_parameter("3.5", "lineprops")
2592+
def __init__(self, ax, onselect, drawtype='box',
2593+
minspanx=0, minspany=0, useblit=False,
2594+
lineprops=None, rectprops=None, spancoords='data',
2595+
button=None, handle_grab_distance=10, handle_props=None,
2596+
interactive=False, state_modifier_keys=None,
2597+
drag_from_anywhere=False):
25992598
super().__init__(ax, onselect, useblit=useblit, button=button,
26002599
state_modifier_keys=state_modifier_keys)
26012600

0 commit comments

Comments
 (0)