【发布时间】:2017-11-20 15:09:15
【问题描述】:
我有这个 python 代码:
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
n = 100
x = np.random.randn(n)
def update(curr):
if curr == n:
a.event_source.stop()
plt.cla()
bins = np.arange(-4,4,0.5)
plt.hist(x[:curr],bins = bins)
plt.gca().set_title('Samplng the Normal distribution')
plt.gca().set_ylabel('Frequency')
plt.gca().set_xlabel('Value')
plt.annotate('n = {}'.format(curr), [3,27])
fig = plt.figure()
a = animation.FuncAnimation(fig, update, interval = 100)
它应该每 3 次绘制更新一次正态分布图,但是当我运行它时,我的图是空的,没有任何反应。你知道为什么吗?
谢谢!
【问题讨论】:
标签: python animation matplotlib spyder