Skip to content

Instantly share code, notes, and snippets.

@lpraat
Created August 8, 2019 10:44
Show Gist options
  • Select an option

  • Save lpraat/0a14ccc6efc013e1701f1f639d2ac18e to your computer and use it in GitHub Desktop.

Select an option

Save lpraat/0a14ccc6efc013e1701f1f639d2ac18e to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
from matplotlib import animation
import numpy as np
fig = plt.figure()
ax = plt.axes(xlim=(-2,5), ylim=(0,10))
line, = ax.plot([], [])
def init():
line.set_data([], [])
def animate(i):
x = [x*i for x in range(10)]
y = [np.random.randint(100) for _ in range(10)]
line.set_data(x, y)
ax.set_xlim(0, max(x) + 5)
ax.set_ylim(0, max(y))
anim = animation.FuncAnimation(
fig,
animate,
init_func=init,
frames=200, interval=20, blit=False)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment