我正在尝试在 matplotlib 中绘制一条线。我正在寻找正确的插值类型。我想要这样的东西
每条线都被平滑。我尝试了scipy和matplotlib的几种组合,例如
x_new = np.arange(x, x_length, 1)
tck = interpolate.splrep(x, y, s=3)
y_new = interpolate.splev(x_new, tck, der=0)
ax.plot(x_new, y_new, color+lstyle)
但我得到的最好结果是
该线代表一个增加的变量..所以它是一个错误的表示。我可以搜索什么?
谢谢
编辑:我正在考虑自己实现一个方法,但我不知道它是否已经完成..伪代码如下
take x and y
calculate spline for each three points
x[0], x[1], x[2] ... x[1], x[2], x[3] ... and so on
for each y[n] sums every computation done for it and divide by number of
computations (i.e. y[1] is computed for triplette x[0..2] and x[1..3] so the
sum is divided by two (average for each point is taken as its value)