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

Fix AxesWidgets on inset_axes that are outside their parent.#29966

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
anntzer wants to merge1 commit intomatplotlib:main
base:main
Choose a base branch
Loading
fromanntzer:outset-widget
Open
Show file tree
Hide file tree
Changes fromall commits
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
43 changes: 23 additions & 20 deletionslib/matplotlib/tests/test_widgets.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -623,27 +623,30 @@ def test_rectangle_selector_ignore_outside(ax, ignore_event_outside):
('horizontal', False, dict(interactive=True)),
])
def test_span_selector(ax, orientation, onmove_callback, kwargs):
onselect = mock.Mock(spec=noop, return_value=None)
onmove = mock.Mock(spec=noop, return_value=None)
if onmove_callback:
kwargs['onmove_callback'] = onmove

# While at it, also test that span selectors work in the presence of twin axes on
# top of the axes that contain the selector. Note that we need to unforce the axes
# aspect here, otherwise the twin axes forces the original axes' limits (to respect
# aspect=1) which makes some of the values below go out of bounds.
# Also test that span selectors work in the presence of twin axes or for
# outside-inset axes on top of the axes that contain the selector. Note
# that we need to unforce the axes aspect here, otherwise the twin axes
# forces the original axes' limits (to respect aspect=1) which makes some
# of the values below go out of bounds.
ax.set_aspect("auto")
tax = ax.twinx()

tool = widgets.SpanSelector(ax, onselect, orientation, **kwargs)
do_event(tool, 'press', xdata=100, ydata=100, button=1)
# move outside of axis
do_event(tool, 'onmove', xdata=199, ydata=199, button=1)
do_event(tool, 'release', xdata=250, ydata=250, button=1)

onselect.assert_called_once_with(100, 199)
if onmove_callback:
onmove.assert_called_once_with(100, 199)
ax.twinx()
child = ax.inset_axes([0, 1, 1, .05], xlim=(0, 200), ylim=(0, 200))

for target in [ax, child]:
onselect = mock.Mock(spec=noop, return_value=None)
onmove = mock.Mock(spec=noop, return_value=None)
if onmove_callback:
kwargs['onmove_callback'] = onmove

tool = widgets.SpanSelector(target, onselect, orientation, **kwargs)
do_event(tool, 'press', xdata=100, ydata=100, button=1)
# move outside of axis
do_event(tool, 'onmove', xdata=199, ydata=199, button=1)
do_event(tool, 'release', xdata=250, ydata=250, button=1)

onselect.assert_called_once_with(100, 199)
if onmove_callback:
onmove.assert_called_once_with(100, 199)


@pytest.mark.parametrize('interactive', [True, False])
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp