@@ -1930,61 +1930,81 @@ def toggle_selector(event):
1930
1930
_shape_klass = Rectangle
1931
1931
1932
1932
def __init__ (self , ax , onselect , drawtype = 'box' ,
1933
- minspanx = None , minspany = None , useblit = False ,
1933
+ minspanx = 0 , minspany = 0 , useblit = False ,
1934
1934
lineprops = None , rectprops = None , spancoords = 'data' ,
1935
1935
button = None , maxdist = 10 , marker_props = None ,
1936
1936
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.
1940
1955
1941
- onselect(pos_1, pos_2)
1956
+ minspanx : float, default: 0
1957
+ Selections with an x-span less than *minspanx* are ignored.
1942
1958
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 .
1945
1961
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).
1948
1965
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::
1950
1969
1951
- rectprops = dict(facecolor='red', edgecolor = 'black',
1952
- alpha=0.2, fill=True)
1970
+ dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
1953
1971
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::
1955
1975
1956
- lineprops = dict(color='black', linestyle='-',
1957
- linewidth = 2, alpha=0.5)
1976
+ dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
1958
1977
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.
1961
1981
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.
1965
1984
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 .
1969
1988
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.
1972
1992
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.
1975
1996
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.
1978
2000
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".
1981
2006
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.
1988
2008
"""
1989
2009
_SelectorWidget .__init__ (self , ax , onselect , useblit = useblit ,
1990
2010
button = button ,
0 commit comments