Help ploting bars

Hello everyone,

I am trying to use matplotlib to plot several bar charts inside a for loop the problem is that I get the first one, but once I close it I cannot plot anymore.

I still get the window but no image appear and eventually python crashes.

Here is my code:


def plot(self):

xCoord = []

yCoord = []

xCoordP = []

yCoordP = []

pylab.Figure()

for i in xrange(self.length-self.length/2):

if i==0 or i%self.size==0:

xCoordP.append(i)

yCoordP.append(self.counts[i])

else:

xCoord.append(i)

yCoord.append(self.counts[i])

bar1, = pylab.subplot(211)

pylab.bar(xCoord,yCoord,color='blue')

pylab.bar(xCoordP,yCoordP,color='red')

xCoord = []

yCoord = []

xCoordP = []

yCoordP = []

for i in xrange(self.length/2,self.length):

if (i+1)%self.size==0:

xCoordP.append(i-self.length/2)

yCoordP.append(self.counts[i])

else:

xCoord.append(i-self.length/2)

yCoord.append(self.counts[i])

bar2, = pylab.subplot(212)

pylab.bar(xCoord,yCoord,color='blue')

pylab.bar(xCoordP,yCoordP,color='red')

pylab.show()

.

.

.

.

for matches,value,n,k in self.lsResults:

self.plot()

Thank you in advance for any help.