title: Calculate angle (degrees) in Python between line (with slope x) and horizontal
body: <p>I need to calculate the angle between a line and the horizontal. My high school maths seems to be failing me.</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  x = [8450.0, 8061.0, 7524.0, 7180.0, 8247.0, 8929.0, 8896.0, 9736.0, 9658.0, 9592.0]
  y = range(len(x))
  
  best_fit_line = np.poly1d(np.polyfit(y, x, 1))(y)
  
  slope = (y[-1] - y[0]) / (x[-1] - x[0])
  angle = np.arctan(slope)
  
  print 'slope: ' + str(slope)
  print 'angle: ' + str(angle)
  
  plt.figure(figsize=(8,6))
  plt.plot(x)
  plt.plot(best_fit_line, '--', color='r')
  plt.show()
  </code></pre>
  
  <p>The results are as follow:</p>
  
  <pre><code>slope: 0.00788091068301
  angle: 0.00788074753125
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/mn1sZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mn1sZ.png" alt="slope of best-fit line"></a></p>
  
  <p>I need the angle between the horizontal and the red dotted line. Just by looking at it, it should probably be something between 30-45 degrees. What am I doing wrong?</p>
  
  <p><em>* regarding <code>slope = (y[-1] - y[0]) / (x[-1] - x[0])</code>, I have also tried <code>numpy.diff</code> and <code>scipy.stats.linregress</code>, but no success either.</em></p>