Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2.  
  3. import numpy as np
  4. import matplotlib.pyplot as plt
  5. from matplotlib.animation import FuncAnimation
  6.  
  7. fig, ax = plt.subplots()
  8. xdata, ydata = [], []
  9. ln, = plt.plot([], [], lw=3)
  10. a = 0
  11. b = 0
  12.  
  13.  
  14. def init():
  15. ax.set_xlim(0, 50*np.pi)
  16. ax.set_ylim(-20, 20)
  17. return ln,
  18.  
  19.  
  20. def update(frame):
  21. xdata.append(a*frame-b*np.sin(frame))
  22. ydata.append(a-b*np.cos(frame))
  23. ln.set_data(xdata, ydata)
  24. return ln,
  25.  
  26.  
  27. a = int(input("daj a"))
  28. b = int(input("Podaj b "))
  29.  
  30. ani = FuncAnimation(fig, update, frames=np.linspace(
  31. 0, 20*np.pi, 1000),
  32. init_func=init, interval=5, blit=True, repeat=False)
  33. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement