imshow(), set_data() and sequential update problem with two figures

Hi,

I am having some difficulties understanding the following matplotlib behavior.

The script below draws two plots and then updates each one with new data. The

imshow() command is used to set the initial data. The data is then updated with

the set_data() method of the return object from imshow(). The second plot

works fine, however, the first plot does not update itself after the set_data() command

and subsequent draw() command. I am baffled as to the reason for this and was wondering

what the correct behavior should be.

I am using matplotlib version ‘0.87.7’, numpy version ‘1.0’ and python version ‘2.4.2’.

Cheers

The script.

···

import pylab, numpy

pylab.ion()

make figure 0, works fine

fig0 = pylab.figure()

pylab.title(‘data0’)

image0 = pylab.imshow(numpy.zeros((2,2), ‘d’))

pylab.colorbar()

pylab.draw()

raw_input(‘fig 0’)

make figure 1, works fine

fig1 = pylab.figure()

pylab.title(‘data1’)

image1 = pylab.imshow(numpy.zeros((2,2), ‘d’))

pylab.colorbar()

pylab.draw()

raw_input(‘fig 1’)

redraw figure 0 with new data, this figure does not update itself

newdata = numpy.array(((0.,1.),(2.,3.)))

pylab.figure(fig0.number)

image0.set_data(newdata)

pylab.clim(vmax=3, vmin=0)

pylab.draw()

raw_input(‘fig 0’)

redraw figure 1 with new data, works fine

pylab.figure(fig1.number)

image1.set_data(newdata)

pylab.clim(vmax=3, vmin=0)

pylab.draw()

raw_input(‘fig 1’)

Daniel Wheeler