Polynomial fitting with log log plot
Posted
by
viral parekh
on Stack Overflow
See other posts from Stack Overflow
or by viral parekh
Published on 2012-09-27T14:20:37Z
Indexed on
2012/09/29
9:37 UTC
Read the original article
Hit count: 295
I have a simple problem to fit a straight line on log-log scale. My code is,
data=loadtxt(filename)
xdata=data[:,0]
ydata=data[:,1]
polycoeffs = scipy.polyfit(xdata, ydata, 1)
yfit = scipy.polyval(polycoeffs, xdata)
pylab.plot(xdata, ydata, 'k.')
pylab.plot(xdata, yfit, 'r-')
Now I need to plot fit line on log scale so I just change x and y axis,
ax.set_yscale('log')
ax.set_xscale('log')
then its not plotting correct fit line. So how can I change fit function (in log scale) so that it can plot fit line on log-log scale?
Thanks
-Viral
© Stack Overflow or respective owner