【发布时间】:2016-11-13 01:03:59
【问题描述】:
我编写了以下脚本来显示一个简单的正弦曲线来无限更新:
#!/usr/bin/env python
import seaborn as sns
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import numpy as np
from math import sin
n = 0
As =[]
Ns = []
def animate(i):
As.append(sin(n))
Ns.append(n)
ax1.plot(np.array(Ns),np.array(As))
while True:
fig1 = plt.figure()
ax1 = fig1.add_subplot(1,1,1)
ani1 = animation.FuncAnimation(fig1, animate, interval=1)
n = n + 0.05
plt.show()
但是,当我尝试关闭窗口时,这条线只会更新(就像完全改变形状一样),我找不到任何东西来解决这个问题 - 该怎么做?非常感谢。
【问题讨论】:
标签: python animation matplotlib graph graphics