I want to update subplots based on a SpanSelector which works as expected. But another requirement is that I need to initialize the selected span to some given values. I have tried to call the _press
, _release
functions but they just return False
and nothing happens. How can I set the span programmatically such that the selected span is visible in the SpanSelector as well?
from matplotlib.widgets import SpanSelector
from collections import namedtuple
widgets.append(
SpanSelector(range_ax, onselect=self._plot_subplots, direction='horizontal', rectprops=dict(alpha=0.5, facecolor='red'), span_stays=True)
)
# fake some events
Event = namedtuple('Event', ['xdata', 'ydata'])
widgets[0]._press(Event(0, 119))
widgets[0]._release(Event(500, 120))