相关疑难解决方法(0)

如何用numpy/scipy/matplotlib绘制线条(多边形链),最小化平滑度

我试图在matplotlib中绘制一条线.我正在寻找正确的插值类型..我想要这样的东西

取自canvasxpress.org/line.html

每条线都经过平滑处理.我尝试了几种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)
Run Code Online (Sandbox Code Playgroud)

但我得到的最好结果是

我的结果

该线表示增加的变量 ..因此它是错误的表示.我可以搜索什么?

谢谢

编辑:我正在考虑从我自己实现一个方法,但我不知道它是否已经完成..伪代码如下

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 …
Run Code Online (Sandbox Code Playgroud)

python numpy matplotlib spline scipy

8
推荐指数
1
解决办法
4118
查看次数

标签 统计

matplotlib ×1

numpy ×1

python ×1

scipy ×1

spline ×1