1

I want to fit y=mx+c straight line to my data points, but in log form. For this purpose I am using curve_fit module. My simple code is

def func(x,m,c):
  return (x*m + c)
x=log10(xdata)
y=log10(ydata)
err=log10(error)
coeff, var = curve_fit(func,x,y,sigma=err)
yfit = func(x,coeff[0],coeff[1])
pl.plot(x,y,'r0')
pl.plot(x,yfit,'k-')
pl.show()

This plot gives me negative numbers on y axis as my y values are in mV. Is there any way to use original xdata and ydata (in mV) on plots with log fitting?

1 Answer 1

1

Plot transformed variables instead.

plot(10**x, 10**yfit, 'k-')

and maybe display the plot in log scale

set_yscale('log')

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.