Can someone point me to the "best" way to dynamically update a 2D [image] array (think of cellular automata)? E.g., this simple example works, but gets sluggish after several iterations:

import numpy as N

import pylab as P

nx = 20

ny = 20

c = N.zeros(nx*ny, dtype='int8')

c.resize(ny,nx)

iters = 50

for its in range(iters):

ix0 = N.random.rand()*nx

iy0 = N.random.rand()*ny

c[iy0,ix0] = 1

P.imshow(c,interpolation='nearest')

P.draw()

I'm guessing I'll want to use the mpl's API, but unsure of the best approach. I'm currently using mpl 0.98.5.

thanks, Randy