Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement