Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. x = np.linspace(1,1.50,10)
  4. print(x.round(2))
  5. y= np.arange(-10,10,1)
  6. print(y)
  7. a= 3
  8. c=1
  9. lin = 2*x
  10. quad=3*x**2 +1*x
  11. deriv = 2*x-5
  12. l = '2x'
  13. q= ' x**2'
  14. d= ' 2x-5 '
  15.  
  16.  
  17. #leg = [l,q,d]
  18. #plt.plot(lin)
  19. #plt.plot(quad)
  20. #plt.plot(deriv)
  21. #plt.legend(leg, loc='upper left')
  22. #plt.show()
  23.  
  24. x=np.arange(-10,10,1)
  25. a=3
  26. c=1
  27.  
  28. eq = a*x**2 +c*x
  29. deriv = 2*a*x+c
  30.  
  31. plt.plot(eq)
  32. plt.plot(deriv)
  33. plt.show()
  34.  
  35.  
  36. fig = plt.gcf()
  37. fig.show()
  38. fig.canvas.draw()
  39. i=1
  40. x=np.arange(-1,0.5,0.2)
  41. a=0.5
  42. c=0.1
  43. for i in range(10):
  44.  
  45. plt.cla()
  46. plt.clf()
  47. plt.plot(eq) # plot equation
  48. plt.plot(deriv)
  49. # update canvas immediately
  50. plt.xlim([-20, 40])
  51. plt.ylim([-20, 100])
  52. fig.canvas.draw()
  53. plt.pause(0.5)
  54. x=np.arange(-10+i,10+i,1)
  55. eq = a*x**2 +c*x
  56. deriv = 2*a*x+c
  57. i+=1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement