from scipy.optimize import curve_fit popt, pcov = curve_fit(func, x, y, p0) # x & y are data points and p0 is an array for the initial guess plt.plot(x, func(x, *popt))