title: On fitting a curved line to a dataset in Python
body: <p>I have a plot with two data sets which produces a slight gradient, where a <strong>curved line of best fit</strong> may be overplotted. </p>
  
  <p>At the moment I have only managed to get a straight line of best fit. I understand <code>scipy.optimize.curve_fit</code> should be able to help me, but this requires me to know the function I want to overplot (I think).</p>
  
  <p>Below are my code and plots. How would one go about creating a curved plot for these data sets? </p>
  
  <pre><code>plt.figure(figsize=(15,6.6))
  pl.subplot(1,2,1) 
  plt.plot(gg,AA, 'kx')
  plt.xlabel('x')
  plt.ylabel('y')
  plt.gca().invert_yaxis()
  y=AA
  x=gg
  fit=pl.polyfit(x,y,1)
  #slope, fit_fn=pl.poly1d(fit)
  fit_fn=pl.poly1d(fit)
  scat=pl.plot(x,y, 'kx', x,fit_fn(x), '-b' )
  
  
  pl.subplot(1,2,2) 
  pl.plot(LL,pp, 'kx')#shows points with no removal or bestfit
  plt.gca().invert_yaxis()
  
  plt.savefig('1.jpg')
  plt.show()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/KoKmt.jpg" alt="my plots the left one has the straight line of best fit"></p>
  
  <p>It should be noted that there is possibly no curve but I want to discover if there is one which would fit. </p>