Hi All:

I’m using the following code to create and display an image with a colorbar.  Later on, I read data from a file and update the image.  

How do I refresh the colorbar to match this new data?  Uncommenting the line in my “ReadFromFile” call below generates a new colorbar.  I’d just like to replace the existing one to match the new data.

I’m using Python 2.5.2, wx 2.8.7.1, and Matplotlib 0.98.5.2 on win32.

THANXS

amb

 

    #################################################################################################

    def SetupPlot(self):

        self.figure = Figure()

        self.axes = self.figure.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.data = np.zeros((self.numChans,self.pageSizeSamps))

        self.myImage = self.axes.imshow(self.data,aspect='auto')

        self.cbar = self.figure.colorbar(self.myImage,ticks=[0,100],orientation='horizontal')

        self.sizer.Add(self.canvas,pos=(1,1),span=(1,2))

        self.add_toolbar() 

    #################################################################################################

    def ReadFromFile(self):

        if self.filename=="":

            print "pick a file first!"

        else:

            # bunch of code to read from file via numpy fromfile lives here…

            self.image_data = abs(fftshift(data,axes=[0]))

            self.myImage = self.axes.imshow(self.image_data,aspect='auto',extent=[self.pageOffset,self.pageOffset+self.pageSizeSamps,0,self.numChans])

            #self.cbar = self.figure.colorbar(self.myImage,orientation='horizontal')

            self.canvas.draw()