0

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 :

enter image description here

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

Tiera Eyek
  • 7
  • 10

1 Answers1

1

Before declaring self.RS use the following:

    try:
        self.RS.set_visible(False)
    except:
        pass
Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60
  • thank you again for help .. i need some idea in my code app please why i have error no attribut when i plot , i didn't see any error in all panel but i have this error please if you can help and thank you for all [https://stackoverflow.com/questions/56157011/how-i-can-fix-error-no-attribut-when-plot-figure-in-subpanel-wxpython] – Tiera Eyek May 16 '19 at 20:08