smooth peaks in gnuplot

假装没事ソ 提交于 2019-11-28 11:34:43

Smoothing with acsplines draws an approximating cubic spline, which doesn't go through your original data points.

A better approach could be to use cubic splines smooth csplines, which go through all data points but may show overshoots for sharp peaks.

The probably best solution in your case is to use monotonic cubic splines, smooth mcsplines, which maintain the monotonicity and convexity of the original data points (see F.N. Fritsch and R.E. Carlson, "Monotone Piecewise Cubic Interpolation", SIAM Journal on Numerical Analysis 17, pp. 238-246 (1980)).

Here is a short example which shows these differences:

The test.dat file contains the points

0 0
0.2 1
0.4 10
0.6 80
1 30
2 20
3 13
4 7
5 2
6 1 
7 0

And the script to plot them is

set xzeroaxis
set style data lines
set samples 500
plot 'test.dat' u 1:2 smooth acsplines title 'acsplines', \
     '' u 1:2 smooth csplines title 'csplines', \
     '' u 1:2 smooth mcsplines lw 2 title 'mcsplines',\
     '' u 1:2 w p pt 7 title 'data points'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!