赞
踩
- # -*- coding: utf-8 -*-
-
- import numpy as np
- import math
- import matplotlib.pyplot as plt
- import matplotlib.animation as antt
-
- fig = plt.figure()
- fig.handle=False
-
- img = fig.add_subplot(111)
-
- x=[]
- y=[]
- for i in range(0,100):
- x.append(i/100.0)
- y.append(math.sin(i/100.0))
-
- #a, = img.plot(np.array(x),'green')
-
- def dtt(data):
- global x,y
- for i in range(0,100):
- y[i]=math.sin(x[i])
- a,=img.plot(np.array(x),np.array(y),'green')
- #a.set_ydata(np.array(y))
- return a,
-
- def dong():
- global x
- while True:
- for i in range(0,100):
- x[i]+=0.5
- yield np.array(x)
-
-
-
- gif = antt.FuncAnimation(fig, dtt, dong, interval=10)
-
- plt.show()
- gif.save("picture.gif",writer="pillow",fps=3000)
-
-
-

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。