On Sun, Dec 4, 2011 at 9:59 AM, Manuel Jung <mjung@astrophysik.uni-kiel.de> wrote:
Hi,

I have plt.pcolormesh plot i would like to animate. So i've taken a
look at the various examples and decided to go with the FuncAnimation
routine. This works for me, but im using for every frame a new call to
plt.colormesh and i am not updating the underlaying data, like in this
example
http://matplotlib.sourceforge.net/examples/animation/dynamic_image.html
This is because there seems to be no set_data, set_array or similar
for the from plt.colormesh returned object (an instance of
matplotlib.collection.QuadMesh). Am i right? Is there any way i can
update the data structures of plt.colormesh?

Hi Manuel,

You can call QuadMesh's `set_array` method, just as you can for images. (You suggest there is no set_array method for QuadMesh; are you sure about that?) The strange part is that it expects a 1d array, where as colormesh accepts arrays of various dimensions.

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> mesh = plt.pcolormesh(np.random.rand(10,10))
>>> mesh.set_array(np.random.rand(10,10).ravel())
>>> plt.draw()

set_array doesn't complain if you remove the call to `ravel`, but `plt.draw()` will complain.

-Tony