Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. %matplotlib nbagg
  2.  
  3. from scipy import stats
  4. import numpy as np
  5. import matplotlib.pyplot as plt
  6. from matplotlib import collections as mc
  7.  
  8. x = [2000, 2001, 2007, 2008, 2013, 2014, 2015, 2016]
  9. y = [5, 8, 14, 18, 38, 46, 63, 72]
  10.  
  11. slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
  12.  
  13. np_x = np.array(x)
  14. np_y = np.array(y)
  15. z2 = np.polyfit(x, y, 2)
  16. s2 = (z2[0] * (t**2)) + (z2[1] * t) + z2[2]
  17.  
  18. z3 = np.polyfit(x, y, 3)
  19. print(z3)
  20. s3 = (z3[0] * (t**3)) + (z3[1] * (t**2)) + (z3[2] * t) + z3[3]
  21.  
  22.  
  23. lines = [[(x[i], y[i]), (x[i], slope*x[i] + intercept)] for i in range(len(x))]
  24. c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
  25. lc = mc.LineCollection(lines, colors=(1,0,0))#, linewidths=2)
  26. ax = plt.axes()
  27. #ax.add_collection(lc)
  28.  
  29. t = np.arange(2000, 2025, 1)
  30. s = slope*t + intercept
  31. #plt.plot(t, s)
  32. plt.plot(t, s2)
  33. #plt.plot(t, s3)
  34. plt.plot(x, y, 'ro')
  35.  
  36. plt.xlabel('Year')
  37. plt.ylabel('Carbon Five employee count')
  38. plt.title('Carbon Five Employee Growth Over Time')
  39. plt.grid(True)
  40. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement