'Fit data with scipy

I have two datasets, calculated from different equations, now I would like to fit both datasets to the same trend line, or to fit one dataset to another. I would like to constrain the blue dataset, with the orange dataset and to get the red trendline, I was wondering if I could use SciPy (scipy.optimize.leastsq or scipy.optimize.curve_fit) but I don't know how, and I don't understand the instruction, because they ask for a function as input, and this is exactly what I want, the function, I have the points (x,y). enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source