Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %matplotlib nbagg
- from scipy import stats
- import numpy as np
- import matplotlib.pyplot as plt
- from matplotlib import collections as mc
- x = [2000, 2001, 2007, 2008, 2013, 2014, 2015, 2016]
- y = [5, 8, 14, 18, 38, 46, 63, 72]
- slope, intercept, r_value, p_value, std_err = stats.linregress(x,y)
- np_x = np.array(x)
- np_y = np.array(y)
- z2 = np.polyfit(x, y, 2)
- s2 = (z2[0] * (t**2)) + (z2[1] * t) + z2[2]
- z3 = np.polyfit(x, y, 3)
- print(z3)
- s3 = (z3[0] * (t**3)) + (z3[1] * (t**2)) + (z3[2] * t) + z3[3]
- lines = [[(x[i], y[i]), (x[i], slope*x[i] + intercept)] for i in range(len(x))]
- c = np.array([(1, 0, 0, 1), (0, 1, 0, 1), (0, 0, 1, 1)])
- lc = mc.LineCollection(lines, colors=(1,0,0))#, linewidths=2)
- ax = plt.axes()
- #ax.add_collection(lc)
- t = np.arange(2000, 2025, 1)
- s = slope*t + intercept
- #plt.plot(t, s)
- plt.plot(t, s2)
- #plt.plot(t, s3)
- plt.plot(x, y, 'ro')
- plt.xlabel('Year')
- plt.ylabel('Carbon Five employee count')
- plt.title('Carbon Five Employee Growth Over Time')
- plt.grid(True)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement