title: scipy.curve_fit() returns multiple lines
body: <p>I am new to python and was trying to fit dataset distribution using the following code. The actual data is a list that contains two columns- predicted market price and actual market price. And I was trying to use <code>scipy.curve_fit()</code> but it gave me many lines plotted at the same place. Any help is appreciated.</p>
  <pre><code># import the necessary modules and define a func.
  from scipy.optimize import curve_fit
  from matplotlib import pyplot as plt
  
  def func(x, a, b, c):
      return a * x** b + c
  
  # my data
  pred_data = [3.0,1.0,1.0,7.0,6.0,1.0,7.0,4.0,9.0,3.0,5.0,5.0,2.0,6.0,8.0]
  actu_data =[ 3.84,1.55,1.15,7.56,6.64,1.09,7.12,4.17,9.45,3.12,5.37,5.65,1.92,6.27,7.63]
  popt, pcov = curve_fit(func, pred_data, actu_data)
  
  #adjusting y 
  yaj = func(pred_data, popt[0],popt[1], popt[2])
  
  # plot the data
  plt.plot(pred_data,actu_data, 'ro', label = 'Data')
  plt.plot(pred_data,yaj,'b--', label = 'Best fit')
  
  plt.legend()
  plt.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/rIZu3.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rIZu3.jpg" alt="enter image description here" /></a></p>