I have a plot with a time series and one or several axvspan lines to highlight some areas and to extract the time series value and instant but I would like to have the possibility to delete one or all those axvspan lines with a button. I have looked some examples on how to delete lines (How can I delete plot lines that are created with Mouse Over Event in Matplolib?) but I can´t find nothing related with axvspan lines. This is the code that I'm using to create the axvspan line(s)
def on_click(event):
global x0
x0 = event.xdata
def on_release(event):
global force_values
if force_value == "Min":
self.axes.axvspan(x0,event.xdata, facecolor='y', alpha=0.5)
get_data(frames,force_values,x0,event.xdata)
else:
self.axes.axvspan(x0,event.xdata, facecolor='r', alpha=0.5)
get_data(frames,force_values,x0,event.xdata)
Thanks in advance for your help. Kind Regards Ivo