Skip to content
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

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

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

@ksunden ksunden merged commit bc1c5cc into matplotlib:main Dec 4, 2023
42 checks passed
@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.

None yet

3 participants