Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve RectangleSelector Rotation revisited and rebased#26833

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dhomeier wants to merge9 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromdhomeier:selector-rotation
Open
Show file tree
Hide file tree
Changes from1 commit
Commits
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
PrevPrevious commit
NextNext commit
Fix ellipse patch bbox edges and add selector tests
  • Loading branch information
@dhomeier
dhomeier committedJan 28, 2025
commitfc74f9521ff01baf0a33f2990a5d8cd2b2650912
2 changes: 1 addition & 1 deletionlib/matplotlib/patches.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1792,7 +1792,7 @@ def _get_edge_midpoints(self):
the centre of the left-hand edge.
"""
return self.get_patch_transform().transform(
[(0, 0.5), (0.5, 0), (1, 0.5), (0.5, 1)])
[(-1, 0), (0, -1), (1, 0), (0, 1)])


class Annulus(Patch):
Expand Down
29 changes: 18 additions & 11 deletionslib/matplotlib/tests/test_widgets.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -456,7 +456,7 @@ def test_rectangle_resize_square_center(ax):

@pytest.mark.parametrize('selector_class',
[widgets.RectangleSelector, widgets.EllipseSelector])
deftest_rectangle_rotate(ax, selector_class):
deftest_selector_rotate(ax, selector_class):
ax.set_aspect(1)
tool = selector_class(ax, interactive=True)
# Draw rectangle
Expand DownExpand Up@@ -564,10 +564,13 @@ def test_ellipse(ax):
assert_allclose(tool.geometry[:, 0], (70, 100))


def test_rectangle_handles(ax):
tool = widgets.RectangleSelector(ax, grab_range=10, interactive=True,
handle_props={'markerfacecolor': 'r',
'markeredgecolor': 'b'})
@pytest.mark.parametrize('selector_class',
[widgets.RectangleSelector, widgets.EllipseSelector])
def test_selector_handles(ax, selector_class):
"""Test geometry of Rectangle/Ellipse Selector [bounding box]"""
tool = selector_class(ax, grab_range=10, interactive=True,
handle_props={'markerfacecolor': 'r',
'markeredgecolor': 'b'})
tool.extents = (100, 150, 100, 150)

assert_allclose(tool.corners, ((100, 150, 150, 100), (100, 100, 150, 150)))
Expand All@@ -584,7 +587,7 @@ def test_rectangle_handles(ax):
click_and_drag(tool, start=(132, 132), end=(120, 120))
assert_allclose(tool.extents, (108, 138, 108, 138))

# create a new rectangle
# create a new rectangle/ellipse
click_and_drag(tool, start=(10, 10), end=(100, 100))
assert_allclose(tool.extents, (10, 100, 10, 100))

Expand All@@ -596,11 +599,13 @@ def test_rectangle_handles(ax):


@pytest.mark.parametrize('interactive', [True, False])
def test_rectangle_selector_onselect(ax, interactive):
@pytest.mark.parametrize('selector_class',
[widgets.RectangleSelector, widgets.EllipseSelector])
def test_selector_onselect(ax, interactive, selector_class):
# check when press and release events take place at the same position
onselect = mock.Mock(spec=noop, return_value=None)

tool =widgets.RectangleSelector(ax, onselect=onselect, interactive=interactive)
tool =selector_class(ax, onselect=onselect, interactive=interactive)
# move outside of axis
click_and_drag(tool, start=(100, 110), end=(150, 120))

Expand All@@ -613,11 +618,13 @@ def test_rectangle_selector_onselect(ax, interactive):


@pytest.mark.parametrize('ignore_event_outside', [True, False])
def test_rectangle_selector_ignore_outside(ax, ignore_event_outside):
@pytest.mark.parametrize('selector_class',
[widgets.RectangleSelector, widgets.EllipseSelector])
def test_selector_ignore_outside(ax, ignore_event_outside, selector_class):
onselect = mock.Mock(spec=noop, return_value=None)

tool =widgets.RectangleSelector(ax, onselect=onselect,
ignore_event_outside=ignore_event_outside)
tool =selector_class(ax, onselect=onselect,
ignore_event_outside=ignore_event_outside)
click_and_drag(tool, start=(100, 110), end=(150, 120))
onselect.assert_called_once()
assert_allclose(tool.extents, (100.0, 150.0, 110.0, 120.0))
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp