Noob curve fitting

Hi, I can’t make sense of this custom fitting function. It appears to be fitting a curve on a much larger scale than I would like it to. The only variables that could affect the fit are initial estimates (p0) and bounds but modifying either does not yield the desired effect. Something resembling the black dashed curve below is what I’m trying to fit, albeit with minimal data. Any help would be greatly appreciated.

`from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
import numpy as np


def exponential(x, a, b):
return abs(a*(1-2np.exp(-bx)))

pars, cov = curve_fit(f=exponential, xdata=t, ydata=m, p0 = [0, 0], bounds=(-np.inf, np.inf))

fig = plt.figure()
ax = fig.add_axes([0, 0, 1, 1])
ax.scatter(t, m, s=50, color=’#00b3b3’, label=‘Data’)
ax.plot(t, exponential(t, *pars), linestyle=’–’, linewidth=2, color=‘black’)`

Howdy Cj,

the data in the code snippet given does not fit to your picture at all, right? So, it’s hard to see, what you want…

Cheers, Dominik