import numpy as np
from matplotlib import pyplot as plt
from matplotlib.animation import FuncAnimation
plt.style.use('seaborn-pastel')
fig = plt.figure()
n=10
ax = plt.axes(xlim=(0, n), ylim=(-2, 2))
line, = ax.plot([], [], c="blue")
def init():
line.set_data([], [])
return line,
def animate(i):
n = 10
x = np.linspace(0, n, 1000)
y = np.sin(np.pi * (x - 0.01 * i)) * x/n
line.set_data(x, y)
return line,
animation = FuncAnimation(fig, animate, init_func=init,
frames=200, interval=20, blit=True)
animation.save('ex408.gif', writer='imagemagick')
plt.show()
Like this:
Like Loading...
Related
Recent Comments