我想插入一些数据,并将结果绘制在对数刻度 ( pyplot.loglog
) 上。问题是生成的插值看起来很奇怪,并且在对数刻度上绘制时显示不连续性。插入对数缩放数据的最佳方法是什么?
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!
实际上,我通过插入数据日志成功地做到了这一点,但我想知道是否有更简单的方法可以实现相同的结果?
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)))