8000 Merge pull request #17474 from anntzer/rs · QuLogic/matplotlib@16df024 · GitHub
[go: up one dir, main page]

Skip to content

Commit 16df024

Browse files
authored
Merge pull request matplotlib#17474 from anntzer/rs
Numpydocify RectangleSelector docstring.
2 parents 786d18a + 67e2590 commit 16df024

File tree

1 file changed

+57
-37
lines changed

1 file changed

+57
-37
lines changed

lib/matplotlib/widgets.py

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1904,61 +1904,81 @@ class RectangleSelector(_SelectorWidget):
19041904
_shape_klass = Rectangle
19051905

19061906
def __init__(self, ax, onselect, drawtype='box',
1907-
minspanx=None, minspany=None, useblit=False,
1907+
minspanx=0, minspany=0, useblit=False,
19081908
lineprops=None, rectprops=None, spancoords='data',
19091909
button=None, maxdist=10, marker_props=None,
19101910
interactive=False, state_modifier_keys=None):
1911-
r"""
1912-
Create a selector in *ax*. When a selection is made, clear
1913-
the span and call onselect with::
1911+
"""
1912+
Parameters
1913+
----------
1914+
ax : `~matplotlib.axes.Axes`
1915+
The parent axes for the widget.
1916+
1917+
onselect : function
1918+
A callback function that is called after a selection is completed.
1919+
It must have the signature::
1920+
1921+
def onselect(eclick: MouseEvent, erelease: MouseEvent)
1922+
1923+
where *eclick* and *erelease* are the mouse click and release
1924+
`.MouseEvent`\s that start and complete the selection.
1925+
1926+
drawtype : {"box", "line", "none"}, default: "box"
1927+
Whether to draw the full rectangle box, the diagonal line of the
1928+
rectangle, or nothing at all.
19141929
1915-
onselect(pos_1, pos_2)
1930+
minspanx : float, default: 0
1931+
Selections with an x-span less than *minspanx* are ignored.
19161932
1917-
and clear the drawn box/line. The ``pos_1`` and ``pos_2`` are
1918-
arrays of length 2 containing the x- and y-coordinate.
1933+
minspany : float, default: 0
1934+
Selections with an y-span less than *minspany* are ignored.
19191935
1920-
If *minspanx* is not *None* then events smaller than *minspanx*
1921-
in x direction are ignored (it's the same for y).
1936+
useblit : bool, default: False
1937+
Whether to use blitting for faster drawing (if supported by the
1938+
backend).
19221939
1923-
The rectangle is drawn with *rectprops*; default::
1940+
lineprops : dict, optional
1941+
Properties with which the line is drawn, if ``drawtype == "line"``.
1942+
Default::
19241943
1925-
rectprops = dict(facecolor='red', edgecolor = 'black',
1926-
alpha=0.2, fill=True)
1944+
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
19271945
1928-
The line is drawn with *lineprops*; default::
1946+
rectprops : dict, optional
1947+
Properties with which the rectangle is drawn, if ``drawtype ==
1948+
"box"``. Default::
19291949
1930-
lineprops = dict(color='black', linestyle='-',
1931-
linewidth = 2, alpha=0.5)
1950+
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
19321951
1933-
Use *drawtype* if you want the mouse to draw a line,
1934-
a box or nothing between click and actual position by setting
1952+
spancoords : {"data", "pixels"}, default: "data"
1953+
Whether to interpret *minspanx* and *minspany* in data or in pixel
1954+
coordinates.
19351955
1936-
``drawtype = 'line'``, ``drawtype='box'`` or ``drawtype = 'none'``.
1937-
Drawing a line would result in a line from vertex A to vertex C in
1938-
a rectangle ABCD.
1956+
button : `.MouseButton`, list of `.MouseButton`, default: all buttons
1957+
Button(s) that trigger rectangle selection.
19391958
1940-
*spancoords* is one of 'data' or 'pixels'. If 'data', *minspanx*
1941-
and *minspanx* will be interpreted in the same coordinates as
1942-
the x and y axis. If 'pixels', they are in pixels.
1959+
maxdist : float, default: 10
1960+
Distance in pixels within which the interactive tool handles can be
1961+
activated.
19431962
1944-
*button* is the `.MouseButton` or list of `.MouseButton`\s used for
1945-
rectangle selection. Default is *None*, which means any button.
1963+
marker_props : dict
1964+
Properties with which the interactive handles are drawn. Currently
1965+
not implemented and ignored.
19461966
1947-
*interactive* will draw a set of handles and allow you interact
1948-
with the widget after it is drawn.
1967+
interactive : bool, default: False
1968+
Whether to draw a set of handles that allow interaction with the
1969+
widget after it is drawn.
19491970
1950-
*state_modifier_keys* are keyboard modifiers that affect the behavior
1951-
of the widget.
1971+
state_modifier_keys : dict, optional
1972+
Keyboard modifiers which affect the widget's behavior. Values
1973+
amend the defaults.
19521974
1953-
The defaults are:
1954-
dict(move=' ', clear='escape', square='shift', center='ctrl')
1975+
- "move": Move the existing shape, default: no modifier.
1976+
- "clear": Clear the current shape, default: "escape".
1977+
- "square": Makes the shape square, default: "shift".
1978+
- "center": Make the initial point the center of the shape,
1979+
default: "ctrl".
19551980
1956-
Keyboard modifiers, which:
1957-
'move': Move the existing shape.
1958-
'clear': Clear the current shape.
1959-
'square': Makes the shape square.
1960-
'center': Make the initial point the center of the shape.
1961-
'square' and 'center' can be combined.
1981+
"square" and "center" can be combined.
19621982
"""
19631983
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
19641984
button=button,

0 commit comments

Comments
 (0)
0