在 Gnuplot 中从样条拟合中提取值

问题描述 投票:0回答:1

我知道可以使用命令在 gnuplot 中通过数据点绘制样条线

plot 'data' u 1:2 smooth acsplines

但是是否可以在任意点评估样条曲线? IE。我正在寻找像

这样的功能
spline(1.54)

我在 gnuplot 文档中找不到任何关于此的信息。

感谢您的帮助!

CW279

gnuplot
1个回答
0
投票

我的第一个想法是:

  • acsplines
    绘制到表格中(检查
    help table
  • 设置
    samples
    足够大以具有良好的精度(检查
    help samples
  • 使用
    stats
    找到与所需值的最小距离
    x0
    (检查
    help stats
    show var STATS
  • 绘制数据点,acplines和添加一个点

脚本:

### 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

结果:

© www.soinside.com 2019 - 2024. All rights reserved.