我知道可以使用命令在 gnuplot 中通过数据点绘制样条线
plot 'data' u 1:2 smooth acsplines
但是是否可以在任意点评估样条曲线? IE。我正在寻找像
这样的功能spline(1.54)
我在 gnuplot 文档中找不到任何关于此的信息。
感谢您的帮助!
CW279
我的第一个想法是:
acsplines
绘制到表格中(检查 help table
)samples
足够大以具有良好的精度(检查help samples
)stats
找到与所需值的最小距离x0
(检查help stats
和show var STATS
)脚本:
### find a point on acsplines curve
reset session
$Data <<EOD
# x y weight
0 4.0 10
1 5.0 100
2 3.0 10
3 3.5 1
4 2.0 1
5 4.0 1
EOD
set table $acsplines
set samples 1000
plot $Data u 1:2:3 smooth acsplines
unset table
x0 = 1.54
stats $acsplines u 2:(abs($1-x0)) nooutput
plot $Data u 1:2 w p pt 7 lc "red" ti "points", \
'' u 1:2:3 smooth acsplines w l lc "blue" ti "acsplines", \
'+' u (x0):(STATS_pos_min_y) every ::::0 w p pt 7 ps 2 \
lc "web-green" ti sprintf("x=%g, y=%.3f",x0,STATS_pos_min_y)
### end of script
结果: