Skip to content

Rename parameter selectors #20585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Jul 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions doc/api/next_api_changes/deprecations/20585-EP.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Unification of Selector API
~~~~~~~~~~~~~~~~~~~~~~~~~~~
The API for Selector widgets has been unified to use

- *props* for the properties of the Artist representing the selection.
- *handle_props* for the Artists representing handles for modifying the selection.
- *grab_range* for the maximal tolerance to grab a handle with the mouse.

This affects the following parameters and attributes:


RectangleSelector and EllipseSelector
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The *maxdist* argument is deprecated, use *grab_range* instead.
The *rectprops* argument is deprecated, use *props* instead.
The *marker_props* argument is deprecated, use *handle_props* instead.

PolygonSelector
^^^^^^^^^^^^^^^
The *vertex_select_radius* argument and attribute is deprecated, use *grab_range* instead.
The *lineprops* argument is deprecated, use *props* instead.
The *markerprops* argument is deprecated, use *handle_props* instead.
The *maxdist* argument and attribute is deprecated, use *grab_range* instead.

SpanSelector
^^^^^^^^^^^^
The *rectprops* argument is deprecated, use *props* instead.
The *maxdist* argument and attribute is deprecated, use *grab_range* instead.

LassoSelector
^^^^^^^^^^^^^
The *lineprops* argument is deprecated, use *props* instead.
2 changes: 1 addition & 1 deletion examples/widgets/span_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def onselect(xmin, xmax):
onselect,
"horizontal",
useblit=True,
rectprops=dict(alpha=0.5, facecolor="tab:blue"),
props=dict(alpha=0.5, facecolor="tab:blue"),
interactive=True,
drag_from_anywhere=True
)
Expand Down
15 changes: 8 additions & 7 deletions lib/matplotlib/tests/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_rectangle_selector():
check_rectangle(drawtype='none', minspanx=10, minspany=10)

check_rectangle(minspanx=10, minspany=10, spancoords='pixels')
check_rectangle(rectprops=dict(fill=True))
check_rectangle(props=dict(fill=True))


@pytest.mark.parametrize('drag_from_anywhere, new_center',
Expand Down Expand Up @@ -98,7 +98,7 @@ def onselect(epress, erelease):
pass

tool = widgets.EllipseSelector(ax, onselect=onselect,
maxdist=10, interactive=True)
grab_range=10, interactive=True)
tool.extents = (100, 150, 100, 150)

# drag the rectangle
Expand Down Expand Up @@ -152,8 +152,9 @@ def onselect(epress, erelease):
pass

tool = widgets.RectangleSelector(ax, onselect=onselect,
maxdist=10, interactive=True,
marker_props={'markerfacecolor': 'r',
grab_range=10,
interactive=True,
handle_props={'markerfacecolor': 'r',
'markeredgecolor': 'b'})
tool.extents = (100, 150, 100, 150)

Expand Down Expand Up @@ -220,7 +221,7 @@ def onmove(vmin, vmax):
def test_span_selector():
check_span('horizontal', minspan=10, useblit=True)
check_span('vertical', onmove_callback=True, button=1)
check_span('horizontal', rectprops=dict(fill=True))
check_span('horizontal', props=dict(fill=True))


@pytest.mark.parametrize('drag_from_anywhere', [True, False])
Expand Down Expand Up @@ -319,7 +320,7 @@ def onselect(verts):

def test_lasso_selector():
check_lasso_selector()
check_lasso_selector(useblit=False, lineprops=dict(color='red'))
check_lasso_selector(useblit=False, props=dict(color='red'))
check_lasso_selector(useblit=True, button=1)


Expand Down Expand Up @@ -673,7 +674,7 @@ def onselect(verts):
pass

tool = widgets.RectangleSelector(ax_test, onselect,
rectprops={'visible': False})
props={'visible': False})
tool.extents = (0.2, 0.8, 0.3, 0.7)


Expand Down
Loading