KansaiRobot
KansaiRobot

Reputation: 9912

Slope and its relationship with angles

I have been using numpy's polyfit function to get a linear fit to some data. And I have gotten some slopes. However the idea of slopes have gotten my head very confused.

I am getting slopes of 0.0142 and of 391! quite different.

What does a slope of 391 actually means? Take a look at this

import numpy as np
import matplotlib.pyplot as plt
xr=np.arange(100)
yr=0.0142*xr
yr2=391*xr

plt.plot(xr,yr,yr2)

print("The angle is:",np.degrees(np.arctan(391)))

enter image description here

The angle is: 89.8534637990051

There is no way that that angle is 89.8 degrees!

What am I getting wrong?

Upvotes: 2

Views: 907

Answers (1)

Ehsan
Ehsan

Reputation: 12397

slope = 391 means for every unit change in your x, y changes by 391. The angle is fact 89.8 and you cannot see it in your plot because your x and y axis have different scales. If you set them to a same scale (i.e. same unit length) you will see an angle of 89.8.

Upvotes: 5

Related Questions