Here is my code:
import matplotlib.pyplot as plt
plt.loglog(length,time,'--')
where length and time are lists.
How do I find the slope of this graph?
Here is my code:
import matplotlib.pyplot as plt
plt.loglog(length,time,'--')
where length and time are lists.
How do I find the slope of this graph?
If you have matplotlib then I believe you must also have numpy installed. If that's true, then you could use numpy.polyfit to find the slope:
import matplotlib.pyplot as plt
import numpy as np
length=np.random.random(10)
length.sort()
time=np.random.random(10)
time.sort()
slope,intercept=np.polyfit(np.log(length),np.log(time),1)
print(slope)
plt.loglog(length,time,'--')
plt.show()