i have problem when i open file and i plot it i have my figure with my rectangelselector but when i change and choose other file to plot the new figure i have 2 rectangeleselector i don't know how i can update rectangleselector all time when i change figure in the same plot :
self.RS = RectangleSelector(self.axes,self.line_select_callback,
drawtype='box', useblit=False,
button=[1, 3],minspanx=5, minspany=5,
spancoords='pixels',
interactive=True, rectprops = dict(facecolor='None',edgecolor='red',alpha=5,fill=False))
self.RS.to_draw.set_visible(True)
self.RS.extents = (0,10,0,10)
def line_select_callback(self, eclick, erelease):
'eclick and erelease are the press and release events'
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
self.zoom_axes=[x1,x2,y1,y2]
thank you
Before declaring self.RS
use the following:
try:
self.RS.set_visible(False)
except:
pass