title: numpy polyfit will not fit parabola properly
body: <p><a href="https://i.stack.imgur.com/l6OQo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l6OQo.png" alt="bad fit image"></a></p>
  
  <p>I am trying to use polyfit to fit a parabola to the set of data points in "data." My program is working for other data sets that I try, but will not work with my particular data set. </p>
  
  <p>I have tried making sure the x-data is sorted properly in ascending order, and I have tried fitting the data in excel. The fit looks fine in excel.</p>
  
  <pre><code>data = [[0.16888549099999922, 7.127084528823611], [0.16888549199999922, 6.993992044491425], [0.16888549299999922, 6.866362061761786], [0.16888549399999922, 6.744197905413327], [0.16888549499999922, 6.627501951010496], [0.16888549599999922, 6.516275651493945], [0.16888549699999922, 6.41051952560987], [0.16888549799999922, 6.310233194927246], [0.16888549899999922, 6.215415356951307], [0.16888549999999922, 6.1260638293986895], [0.16888550099999922, 6.042175535068139], [0.16888550199999922, 5.963746518271748], [0.16888550299999922, 5.890771966813277], [0.16888550399999921, 5.823246197254835], [0.16888550499999921, 5.761162692791979], [0.1688855059999992, 5.704514090084273], [0.1688855069999992, 5.653292206179698], [0.1688855079999992, 5.6074880385927806], [0.1688855089999992, 5.567091780688852], [0.1688855099999992, 5.532092833944616], [0.1688855109999992, 5.502479813247546], [0.1688855119999992, 5.4782405647173915], [0.1688855129999992, 5.459362171880384], [0.1688855139999992, 5.4458309690410776], [0.1688855149999992, 5.437632552360041], [0.1688855159999992, 5.434751791325787], [0.1688855169999992, 5.43717284006055], [0.1688855179999992, 5.444879149278103], [0.1688855189999992, 5.457853477721287], [0.1688855199999992, 5.47607790389057], [0.1688855209999992, 5.4995338388052435], [0.1688855219999992, 5.52820203573491], [0.1688855229999992, 5.562062602591132], [0.1688855239999992, 5.601095018180885], [0.1688855249999992, 5.645278137030775], [0.1688855259999992, 5.694590207075108], [0.1688855269999992, 5.7490088760994285], [0.1688855279999992, 5.808511211230821], [0.1688855289999992, 5.873073702228439], [0.1688855299999992, 5.942672282488598], [0.1688855309999992, 6.017282332411738], [0.1688855319999992, 6.096878700665825], [0.1688855329999992, 6.1814357028181135], [0.1688855339999992, 6.27092714427376], [0.1688855349999992, 6.365326333275836], [0.1688855359999992, 6.464606084709255], [0.1688855369999992, 6.56873873137477], [0.1688855379999992, 6.677696151240223], [0.1688855389999992, 6.791449748897025], [0.1688855399999992, 6.909970506323868]]
  
  import numpy as np
  import matplotlib
  import matplotlib.pyplot as plt
  
  matplotlib.use('TkAgg')
  
  x = list()
  y = list()
  for i in data:
      x.append(i[0])
      y.append(i[1])
  
  fit = np.polyfit(x, y, 2)
  f = np.poly1d(fit)
  
  plt.scatter(x,y)
  plt.plot(x,f(x))
  plt.xlim(0.16888549099999922 - 0.000000001,0.1688855399999992 + 0.000000001)
  plt.show()
  </code></pre>
  
  <p>I am getting a fit that looks like a line. There is an error that the fit is poorly conditioned. I cannot figure out why this is happening in my code, so I set up this little code that clearly demonstrates the issue. Can anybody help me with this?</p>