title: Use of curve_fit to fit data
body: <p>I'm new to scipy and matplotlib, and I've been trying to fit functions to data. The first example in the <a href="http://www.scipy.org/Cookbook/FittingData" rel="noreferrer" title="Scipy Cookbook">Scipy Cookbook</a> works fantastically, but when I am trying it with points read from a file, the initial coefficients I give (p0 below) never seem to actually change, and the covariance matrix is always INF. </p>
  
  <p>I've tried to fit even data following a line, to no avail. Is it a problem with the way I am importing the data? If so, is there a better way to do it?</p>
  
  <pre><code>import matplotlib.pyplot as plt
  from scipy.optimize import curve_fit
  import scipy as sy
  
  with open('data.dat') as f:
      noms = f.readline().split('\t')
  
      dtipus = [('x', sy.float32)] + [('y', sy.float32)]
  
      data = sy.loadtxt(f,delimiter='\t',dtype=dtipus)
  
      x = data['x']
      y = data['y']
  
      def func(x, a, b, c):
          return a*x**b + c
  
      p0 = sy.array([1,1,1])
  
      coeffs, matcov = curve_fit(func, x, y, p0)
  
      yaj = func(x, coeffs[0], coeffs[1], coeffs[2])
  
      print(coeffs)
      print(matcov)
  
      plt.plot(x,y,'x',x,yaj,'r-')
      plt.show()
  </code></pre>
  
  <p>Thanks!</p>