I've got this weird problem with a very simple piece of code. I've looked at countless examples and they all seem to work fine, but for some reason mine doesn't…
What I'm trying to achieve, is to set the point at which the plotting of the regression model begins. I want it to be, say 5000, instead of zero. At the opposite end it works fine Ie if I set the regression to end at a desired point, it will, but starting at any other point besides zero doesn't work. If I set “start” xFit1 to be a non-zero value, the scaling goes all weird, while the beginning of the plot just remains at zero. What might be going on, any ideas?
AVG_PNTSx = []
u = 0
p = 0
S_O = False
#Array creation
#Add each sample preparation result here manually:
AVG_PNTSy = [14, 30, 64, 130, 300, 400, 1220, 2660, 4939, 10100, 10600, 10900, 10000, 22150, 45000]
#Auto creation of x-array based on y-array
for i in range(len(AVG_PNTSy)):
u = (i*20001)+10000
AVG_PNTSx.append(u)
#Exp Regression
def func(x,a,b):
return a*np.exp(b*x)
xFit1 = np.arange(start,300000,1)
init_guess = [1,0.00001]
popt, pcov = curve_fit(func, AVG_PNTSx, AVG_PNTSy,init_guess)
#Plots
p3, = plt.plot((func(xFit1,*popt)))
plt.plot(AVG_PNTSx,AVG_PNTSy,"ro")
Thanks in advance!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.