title: How to plot error bars in python curve fit?
body: <p>I'm trying to calculate the error bars and plot them in python. I'm completely beginner in python plotting. Could someone's help how can I do that.
  Here is my plot</p>
  <p><a href="https://i.stack.imgur.com/ZKDM8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZKDM8.png" alt="enter image description here" /></a></p>
  <p>Here is my code!! Literally I want the slope and the intercept and fit the deviations to the function. Thanks!!</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  from scipy.optimize import curve_fit
  import matplotlib.pyplot as mpl
  
  &quot;&quot;&quot; Fitting Function&quot;&quot;&quot;
  def func(x, a, b):
      y = a *np.exp(-1*b/x) 
      return y
  data = np.loadtxt(&quot;S005_CP_0011_N20.dat&quot;, skiprows=0, dtype=np.float128)
  xData, yData = np.hsplit(data,2)
  x = xData[:,0]
  y = yData[:,0]
  
  popt, pcov = curve_fit(func, x, y, sigma = None)
  
  fig1= mpl.figure(figsize=(8,6))
  mpl.plot(x, func(x, *popt), label=&quot;Fit function&quot;)
  mpl.plot(x, y, 'r.', markersize=10, label=&quot;data&quot;)
  </code></pre>