How to update pcolormesh data & update plot?

I have a pcolormesh() plot that I would like to update when a user presses a
key. Basically there are data files from 0..N and I want to update the plot
to the next frame when a user presses the 'right' arrow. I have the keypress
event working, I just don't know how to 'update' the data for the

I'm pretty new to matplotlib, so if anyone could help with this it would be
greatly appreciated!
Thanks! (Code snippet below)

def press(event):
  if event.key=='right':
    data2D = readDataFile() #updates data2D
                #update pcolormesh somehow??

#X,Y,data2D are initially set here...
fig = plt.figure()
fig.canvas.mpl_connect('key_press_event', press)
ax = fig.add_subplot(111)
plt.pcolormesh(X, Y, data2D)


View this message in context:
Sent from the matplotlib - users mailing list archive at