def wave1():
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import animation
f = lambda x,t: 2*0.02*np.sin(2*np.pi*x/0.42) * np.cos(2*np.pi*125*t)
fig = plt.figure()
ax = plt.axes(xlim=(0, 1), ylim=(-0.3, 0.3))
line, = ax.plot([], [], lw=2)
def init():
line.set_data([], [])
return line,
def animate(i):
print i
t = i/1000
x = np.linspace(0, 2, 100)
y = f(x,t)
line.set_data(x, y)
return line,
anim = animation.FuncAnimation(fig, animate, init_func=init,
frames=20, interval=200, blit=True)
#plt.show()
anim.save('line.gif', dpi=80, writer='imagemagick')Регистрирани потребители: Google [Bot]