有可能是一个更好的办法来制作动画imshow的,但这应该在紧要关头。这是一个animation example from the docs的轻微修改版本。
# For detailed comments on animation and the techniqes used here, see
# the wiki entry http://www.scipy.org/Cookbook/Matplotlib/Animations
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
import matplotlib.cm as cm
import sys
import numpy as np
import time
ax = plt.subplot(111)
canvas = ax.figure.canvas
delta=0.025
x=y= np.arange(-3.0, 3.0, delta)
x,y=np.meshgrid(x, y)
z1=mlab.bivariate_normal(x, y, 1.0, 1.0, 0.0, 0.0)
z2=mlab.bivariate_normal(x, y, 1.5, 0.5, 1, 1)
z=z2-z1 # difference of Gaussians
def run(z):
fig=plt.gcf()
for i in range(10):
plt.imshow(z, interpolation='bilinear', cmap=cm.gray,
origin='lower', extent=[-3,3,-3,3])
canvas.draw()
plt.clf()
z**=2
manager = plt.get_current_fig_manager()
manager.window.after(100, run, z)
plt.show()
我能为N> = 2创建顺序图。你在用什么IDE(如果你使用的是)?在我得到下一个之前,我必须手动关闭这个图,所以在这个例子中'p.close()'是毫无意义的。 – Paul 2011-03-01 18:38:55
我使用PyCharm编写脚本并运行它。我注意到,这个问题似乎只发生在运行脚本而不是ipython -pylab – 2011-03-01 19:29:16