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?