Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67e2590

Browse files
committed
Numpydocify RectangleSelector docstring.
- The given signature for `onselect` was wrong -- it is called with the start and end events as arguments. - Changed the default of `minspanx`, `minspany` to 0 -- it is easier to document. None is kept as undocumented backcompat; deprecating None would also beed to cover assignment to the `minspanx/y` attributes (probably using a property, yada yada). - `marker_props` is currently ignored, but let's not deprecate it as it would actually make sense to support it (consistently with PolygonSelector -- which names it `markerprops` but heh...).
1 parent 969513e commit 67e2590

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
@@ -1930,61 +1930,81 @@ def toggle_selector(event):
19301930
_shape_klass = Rectangle
19311931

19321932
def __init__(self, ax, onselect, drawtype='box',
1933-
minspanx=None, minspany=None, useblit=False,
1933+
minspanx=0, minspany=0, useblit=False,
19341934
lineprops=None, rectprops=None, spancoords='data',
19351935
button=None, maxdist=10, marker_props=None,
19361936
interactive=False, state_modifier_keys=None):
1937-
r"""
1938-
Create a selector in *ax*. When a selection is made, clear
1939-
the span and call onselect with::
1937+
"""
1938+
Parameters
1939+
----------
1940+
ax : `~matplotlib.axes.Axes`
1941+
The parent axes for the widget.
1942+
1943+
onselect : function
1944+
A callback function that is called after a selection is completed.
1945+
It must have the signature::
1946+
1947+
def onselect(eclick: MouseEvent, erelease: MouseEvent)
1948+
1949+
where *eclick* and *erelease* are the mouse click and release
1950+
`.MouseEvent`\s that start and complete the selection.
1951+
1952+
drawtype : {"box", "line", "none"}, default: "box"
1953+
Whether to draw the full rectangle box, the diagonal line of the
1954+
rectangle, or nothing at all.
19401955
1941-
onselect(pos_1, pos_2)
1956+
minspanx : float, default: 0
1957+
Selections with an x-span less than *minspanx* are ignored.
19421958
1943-
and clear the drawn box/line. The ``pos_1`` and ``pos_2`` are
1944-
arrays of length 2 containing the x- and y-coordinate.
1959+
minspany : float, default: 0
1960+
Selections with an y-span less than *minspany* are ignored.
19451961
1946-
If *minspanx* is not *None* then events smaller than *minspanx*
1947-
in x direction are ignored (it's the same for y).
1962+
useblit : bool, default: False
1963+
Whether to use blitting for faster drawing (if supported by the
1964+
backend).
19481965
1949-
The rectangle is drawn with *rectprops*; default::
1966+
lineprops : dict, optional
1967+
Properties with which the line is drawn, if ``drawtype == "line"``.
1968+
Default::
19501969
1951-
rectprops = dict(facecolor='red', edgecolor = 'black',
1952-
alpha=0.2, fill=True)
1970+
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
19531971
1954-
The line is drawn with *lineprops*; default::
1972+
rectprops : dict, optional
1973+
Properties with which the rectangle is drawn, if ``drawtype ==
1974+
"box"``. Default::
19551975
1956-
lineprops = dict(color='black', linestyle='-',
1957-
linewidth = 2, alpha=0.5)
1976+
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
19581977
1959-
Use *drawtype* if you want the mouse to draw a line,
1960-
a box or nothing between click and actual position by setting
1978+
spancoords : {"data", "pixels"}, default: "data"
1979+
Whether to interpret *minspanx* and *minspany* in data or in pixel
1980+
coordinates.
19611981
1962-
``drawtype = 'line'``, ``drawtype='box'`` or ``drawtype = 'none'``.
1963-
Drawing a line would result in a line from vertex A to vertex C in
1964-
a rectangle ABCD.
1982+
button : `.MouseButton`, list of `.MouseButton`, default: all buttons
1983+
Button(s) that trigger rectangle selection.
19651984
1966-
*spancoords* is one of 'data' or 'pixels'. If 'data', *minspanx*
1967-
and *minspanx* will be interpreted in the same coordinates as
1968-
the x and y axis. If 'pixels', they are in pixels.
1985+
maxdist : float, default: 10
1986+
Distance in pixels within which the interactive tool handles can be
1987+
activated.
19691988
1970-
*button* is the `.MouseButton` or list of `.MouseButton`\s used for
1971-
rectangle selection. Default is *None*, which means any button.
1989+
marker_props : dict
1990+
Properties with which the interactive handles are drawn. Currently
1991+
not implemented and ignored.
19721992
1973-
*interactive* will draw a set of handles and allow you interact
1974-
with the widget after it is drawn.
1993+
interactive : bool, default: False
1994+
Whether to draw a set of handles that allow interaction with the
1995+
widget after it is drawn.
19751996
1976-
*state_modifier_keys* are keyboard modifiers that affect the behavior
1977-
of the widget.
1997+
state_modifier_keys : dict, optional
1998+
Keyboard modifiers which affect the widget's behavior. Values
1999+
amend the defaults.
19782000
1979-
The defaults are:
1980-
dict(move=' ', clear='escape', square='shift', center='ctrl')
2001+
- "move": Move the existing shape, default: no modifier.
2002+
- "clear": Clear the current shape, default: "escape".
2003+
- "square": Makes the shape square, default: "shift".
2004+
- "center": Make the initial point the center of the shape,
2005+
default: "ctrl".
19812006
1982-
Keyboard modifiers, which:
1983-
'move': Move the existing shape.
1984-
'clear': Clear the current shape.
1985-
'square': Makes the shape square.
1986-
'center': Make the initial point the center of the shape.
1987-
'square' and 'center' can be combined.
2007+
"square" and "center" can be combined.
19882008
"""
19892009
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
19902010
button=button,

0 commit comments

Comments
 (0)