我用 pcolor 从二维数组中绘制信息。但是,数组中的信息在迭代过程中会发生变化,我想动态更新颜色图,以便实时可视化变化。我怎样才能以最简单的方式做到这一点?
编辑 - 示例:
from __future__ import division
from pylab import *
import random
n = 50 # number of iterations
x = arange(0, 10, 0.1)
y = arange(0, 10, 0.1)
T = zeros([100,100]) # 10/0.1 = 100
X,Y = meshgrid(x, y)
"""initial conditions"""
for x in range(100):
for y in range(100):
T[x][y] = random.random()
pcolor(X, Y, T, cmap=cm.hot, vmax=abs(T).max(), vmin=0)
colorbar()
axis([0,10,0,10])
show() # colormap of the initial array
"""main loop"""
for i in range(n):
for x in range(100):
for y in range(100):
T[x][y] += 0.1 # here i do some calculations, the details are not important
# here I want to update the color map with the new array (T)
谢谢