@@ -1904,61 +1904,81 @@ class RectangleSelector(_SelectorWidget):
1904
1904
_shape_klass = Rectangle
1905
1905
1906
1906
def __init__ (self , ax , onselect , drawtype = 'box' ,
1907
- minspanx = None , minspany = None , useblit = False ,
1907
+ minspanx = 0 , minspany = 0 , useblit = False ,
1908
1908
lineprops = None , rectprops = None , spancoords = 'data' ,
1909
1909
button = None , maxdist = 10 , marker_props = None ,
1910
1910
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.
1914
1929
1915
- onselect(pos_1, pos_2)
1930
+ minspanx : float, default: 0
1931
+ Selections with an x-span less than *minspanx* are ignored.
1916
1932
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 .
1919
1935
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).
1922
1939
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::
1924
1943
1925
- rectprops = dict(facecolor='red', edgecolor = 'black',
1926
- alpha=0.2, fill=True)
1944
+ dict(color="black", linestyle="-", linewidth=2, alpha=0.5)
1927
1945
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::
1929
1949
1930
- lineprops = dict(color='black', linestyle='-',
1931
- linewidth = 2, alpha=0.5)
1950
+ dict(facecolor="red", edgecolor="black", alpha=0.2, fill=True)
1932
1951
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.
1935
1955
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.
1939
1958
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 .
1943
1962
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.
1946
1966
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.
1949
1970
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.
1952
1974
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".
1955
1980
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.
1962
1982
"""
1963
1983
_SelectorWidget .__init__ (self , ax , onselect , useblit = useblit ,
1964
1984
button = button ,
0 commit comments