I want to interpolate some data, and to plot the result on a log scale (pyplot.loglog). The problem is that the resulting interpolation looks very strange and shows discontinuities when plotted on a log scale. What is the best way to interpolate log scaled data?
pyplot.loglog(x, y, '+')
pyplot.hold(True)
s = scipy.interpolate.InterpolatedUnivariateSpline(x, y)
xs = numpy.logspace(numpy.log10(numpy.min(x)), numpy.log10(numpy.max(x)))
pyplot.loglog(xs, s(xs)) # This looks very strange because of the log scale!
Actually, I succeed doing it by interpolating the log of the data, but I was wondering if there were a simpler way of achieving the same result?
pyplot.loglog(x, y, '+')
pyplot.hold(True)
s = scipy.interpolate.InterpolatedUnivariateSpline(numpy.log10(x), numpy.log10(y))
xs = numpy.logspace(numpy.log10(numpy.min(x)), numpy.log10(numpy.max(x)))
pyplot.loglog(xs, numpy.power(10, s(numpy.log10(xs)))
Looks like taking logarithm of the data first, then fitting is a normal way to do this. See Fitting a Power Law Distribution.