I require a python solution to force a polynomial to end at a specific point. I have read the solutions offered here: How to do a polynomial fit with fixed points to a similar question but have been unable to get any of these methods working on my data set as are not defining end points but locations to for a polynomial to pass through.
I therefore require a solution to force a polynomial curve to end at a specific location.
To put this in context the example that I need this for is shown in the image below, I require a line of best fit for the data below, the green points represent the raw data and the pink points are the mean of the green points for every x value. The best fit should be a 3rd order polynomial until the data becomes a horizontal linear line. The black line is my current attempt at a line of best fit using np.ployfit(), I have defined the polynomial to only plot until the location where I would then start the linear best fit line but as you can see the tail of the polynomial is far to low and hence I want to force it to end / go through a specific point.
I am open to all options to get a nice mathematically sensible best fit as have been banging my head against this problem for too long now.