Skip to content

Instantly share code, notes, and snippets.

@Subv
Created September 28, 2018 17:02
Show Gist options
  • Save Subv/c5f0e72f87f9cb591539c0f364592899 to your computer and use it in GitHub Desktop.
Save Subv/c5f0e72f87f9cb591539c0f364592899 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
fig, ax = plt.subplots()
x = np.arange(0, 2*np.pi, 0.01)
line, = ax.plot(x, np.sin(x))
def init():
# Inicializa los datos
line.set_ydata([np.nan] * len(x))
return line,
def animate(i):
# Actualiza los datos
line.set_ydata(np.sin(x + i / 100))
return line,
ani = animation.FuncAnimation(
fig, animate, init_func=init, interval=2, blit=True, save_count=50)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment