displaying only one colorbar...

Hi,

My issue is quite simple: I reload several times an image
with the colorbar enabled, and thus, I have several colorbars, not only one.

How can I disable this, and thus, get only one colorbar ?

Cheers,

···

--
http://scipy.org/FredericPetit

fred wrote:

Hi,

My issue is quite simple: I reload several times an image
with the colorbar enabled, and thus, I have several colorbars, not only one.

How can I disable this, and thus, get only one colorbar ?

Cheers,

You may need to post a small code example so we can see what you are doing; but an interactive example using ipython -pylab may give you enough information to answer your question:

im = imshow(rand(20,20))
colorbar()

im.set_data(rand(20,20))
draw()

im.set_data(rand(20,20)*5)
im.autoscale() # to change the colormap limits
draw()

etc....

Eric

Eric Firing a �crit :

You may need to post a small code example so we can see what you are doing; but an interactive example using ipython -pylab may give you enough information to answer your question:

Hi ,

Not really ;-), but no problem.

I got a fix.
The trick is to pass axes colorbar as argument to colorbar function:

    def update_colorbar(self):
        if (self.cb is None):
            self.cb = self.display.figure.colorbar(self.img,
                                                   ticks=self.cbticks,
                                                   format='%g')
        else:
            self.display.figure.colorbar(self.img,
                                         self.cb.ax,
                                         ticks=self.cbticks,
                                         format='%g')

that works perfectly.

Cheers,

···

--
http://scipy.org/FredericPetit