title: Compute and plot tangent lines along a curve produced by polynomial regression using np.polyfit
body: <p>A curve is fitted to a data series using np.polyfit and evaluated with np.polyval to plot as:</p>
  
  <p><a href="https://i.stack.imgur.com/e6y1u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e6y1u.png" alt="enter image description here"></a></p>
  
  <p>How do I compute a tangent line at a point on the curve, and how to animate a series of tangent lines along the curve with x and y values in the series?</p>
  
  <p>ps: Thanks to James Phillips' solution, a tangent line on the polynomial curve is plotted below:</p>
  
  <p><a href="https://i.stack.imgur.com/Torna.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Torna.png" alt="Tangent line on a polynomial curve"></a></p>
  
  <pre><code>x     y
  0     21.05
  1     21.21
  2     20.76
  3     20.34
  4     20.27
  5     20.78
  6     20.60
  7     20.55
  8     19.95
  9     19.23
  10    19.64
  11    19.92
  12    19.91
  13    19.56
  14    19.39
  15    19.31
  16    19.35
  17    18.97
  18    18.69
  19    19.00
  20    19.15
  21    19.08
  22    18.97
  23    19.26
  24    19.52
  25    19.56
  26    19.28
  27    19.47
  28    19.85
  29    19.77
  </code></pre>