Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix setting _selection_completed in SpanSelector when spanselector is initialised using extents #27409

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 1 commit into from
Dec 4, 2023

Conversation

ericpre
Copy link
Member

@ericpre ericpre commented Nov 30, 2023

PR summary

In the following example, if the first click is outside of the span selector, the span selector will be reset on the press event, while it shouldn't. The reason is that when setting extents programmatically after initialisation of the span selector, the attribute _selection_completed should be True, otherwise the span selector will behave as the selection was incomplete!

import matplotlib.pyplot as plt

from matplotlib.widgets import SpanSelector

fig, ax = plt.subplots()
ax.plot(range(40))

span = SpanSelector(
    ax,
    onselect=lambda a, b:None,
    direction="horizontal",
    interactive=True,
    drag_from_anywhere=True,
    ignore_event_outside=True,
)

span.extents = (10, 20)

PR checklist

@ericpre ericpre force-pushed the fix_selection_completed branch from c3f7b20 to 1b0fc8f Compare December 1, 2023 17:15
@ericpre ericpre force-pushed the fix_selection_completed branch from 1b0fc8f to 50e70a4 Compare December 2, 2023 10:14
@ksunden ksunden merged commit bc1c5cc into matplotlib:main Dec 4, 2023
@QuLogic QuLogic added this to the v3.9.0 milestone Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants