How to set the min and max value for SpanSelector widget programmatically

Solution 1:

Set the selection rectangle stay_rect and call the onselect handler with the initial xmin and xmax values.

Example: initial view of the example from the docs with the following inserted before plt.show():

xmin, xmax = 3, 4 
span.stay_rect.set_bounds(xmin, 0, xmax-xmin, 1)
span.stay_rect.set_visible(True)
span.onselect(xmin, xmax)

enter image description here