Calculate angle (degrees) in Python between line (with slope x) and horizontal Calculate angle (degrees) in Python between line (with slope x) and horizontal numpy numpy

Calculate angle (degrees) in Python between line (with slope x) and horizontal


The line goes in x-direction from 0 to 9 and in y-direction from 7500 to 9500. Therefore your slope is only 0.00788091068301 and not 0.57 for about 30°. Your calculations are correct, but better use arctan2:

angle = np.rad2deg(np.arctan2(y[-1] - y[0], x[-1] - x[0]))