title: Fit spline through scatter
body: <p>I a have two sets of data of which I want to find a correlation. Although there is quite some scattering of data there's obvious a relation. I currently use numpy polyfit (8th order) but there is some "wiggling" of the line (especially at the beginning and the end) which is not appropriate. Secondly I don't think the fit is very well at the beginning of the line (the curve should be slightly steeper.</p>
  
  <p>How can I get a best fit "spline" through these data points?</p>
  
  <p><a href="https://i.stack.imgur.com/4oVvf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4oVvf.png" alt="Data scatter with polyfit"></a></p>
  
  <p>My current code:</p>
  
  <pre><code># fit regression line
  regressionLineOrder = 8
  regressionLine = np.polyfit(data['x'], data['y'], regressionLineOrder)
  p = np.poly1d(regressionLine)
  </code></pre>