8000 Numpydocify RectangleSelector docstring. · matplotlib/matplotlib@07d134b · GitHub
[go: up one dir, main page]

Skip to content

Commit 07d134b

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 07d134b

File tree

1 file changed

+51
-52
lines changed

1 file changed

+51
-52
lines changed

lib/matplotlib/widgets.py

Lines changed: 51 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1930,61 +1930,60 @@ 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::
1940-
1941-
onselect(pos_1, pos_2)
1942-
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.
1945-
1946-
If *minspanx* is not *None* then events smaller than *minspanx*
1947-
in x direction are ignored (it's the same for y).
1948-
1949-
The rectangle is drawn with *rectprops*; default::
1950-
1951-
rectprops = dict(facecolor='red', edgecolor = 'black',
1952-
alpha=0.2, fill=True)
1953-
1954-
The line is drawn with *lineprops*; default::
1955-
1956-
lineprops = dict(color='black', linestyle='-',
1957-
linewidth = 2, alpha=0.5)
1958-
1959-
Use *drawtype* if you want the mouse to draw a line,
1960-
a box or nothing between click and actual position by setting
1961-
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.
1965-
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.
1969-
1970-
*button* is the `.MouseButton` or list of `.MouseButton`\s used for
1971-
rectangle selection. Default is *None*, which means any button.
1972-
1973-
*interactive* will draw a set of handles and allow you interact
1974-
with the widget after it is drawn.
1975-
1976-
*state_modifier_keys* are keyboard modifiers that affect the behavior
1977-
of the widget.
1978-
1979-
The defaults are:
1980-
dict(move=' ', clear='escape', square='shift', center='ctrl')
1981-
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.
1937+
"""
1938+
Parameters
1939+
----------
1940+
ax : `~matplotlib.axes.Axes`
1941+
The parent axes for the widget.
1942+
onselect : function
1943+
When a selection is made, the selector is cleared and *onselect*
1944+
is called with two arguments: the button press event and button
1945+
release event.
1946+
drawtype : {"box", "line", "none"}, default: "box"
1947+
Whether to draw the full rectangle box, the diagonal line of the
1948+
rectangle, or nothing at all.
1949+
minspanx : float, default: 0
1950+
Selections with an x-span less than *minspanx* are ignored.
1951+
minspany : float, default: 0
1952+
Selections with an y-span less than *minspany* are ignored.
1953+
useblit : bool, default: False
1954+
Whether to use blitting for faster drawing (if supported by the
1955+
backend).
1956+
lineprops : dict, default: \
1957+
dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
1958+
Properties with which the line is drawn, if ``drawtype == "line"``.
1959+
rectprops : dict, default: \
1960+
dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
1961+
Properties with which the rectangle is drawn, if ``drawtype ==
1962+
"box"``.
1963+
spancoords : {"data", "pixels"}
1964+
Whether to interpret *minspanx* and *minspany* in data or in pixel
1965+
coordinates.
1966+
button : `.MouseButton`, list of `.MouseButton`, or None, default: None
1967+
Button(s) that trigger rectangle selection; None means "any
1968+
button".
1969+
maxdist : float, default: 10
1970+
Distance in pixels within which the interactive tool handles can be
1971+
activated.
1972+
marker_props : dict
1973+
Properties with which the interactive handles are drawn. Currently
1974+
not implemented and ignored.
1975+
interactive : bool, default: False
1976+
Whether to draw a set of handles that allow interaction with the
1977+
widget after it is drawn.
1978+
state_modifier_keys : dict, default: \
1979+
dict(move=" ", clear="escape", square="shift", center="ctrl")
1980+
Keyboard modifiers which affect the widget's behavior:
1981+
1982+
- "move": Move the existing shape.
1983+
- "clear": Clear the current shape.
1984+
- "square": Makes the shape square.
1985+
- "center": Make the initial point the center of the shape.
1986+
- "square" and "center" can be combined.
19881987
"""
19891988
_SelectorWidget.__init__(self, ax, onselect, useblit=useblit,
19901989
button=button,

0 commit comments

Comments
 (0)
0