Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. import matplotlib.pyplot as plt
  2. from matplotlib import animation
  3. import numpy as np
  4.  
  5.  
  6. fig = plt.figure()
  7. ax = plt.axes(xlim=(-2,5), ylim=(0,10))
  8. line, = ax.plot([], [])
  9.  
  10.  
  11. def init():
  12. line.set_data([], [])
  13.  
  14.  
  15. def animate(i):
  16. x = [x*i for x in range(10)]
  17. y = [np.random.randint(100) for _ in range(10)]
  18. line.set_data(x, y)
  19. ax.set_xlim(0, max(x) + 5)
  20. ax.set_ylim(0, max(y))
  21.  
  22.  
  23. anim = animation.FuncAnimation(
  24. fig,
  25. animate,
  26. init_func=init,
  27. frames=200, interval=20, blit=False)
  28.  
  29. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement