有人知道如何从给定数据中提取平滑cspline曲线的一些数据吗?
例如,有一个数据文件,它有2列对应于x和y值。我可以通过以下命令绘制具有平滑cpline曲线的数据
p 'data' w lp, "" smooth csplines
我希望能将光滑的cpline曲线提取为另一个数据文件。
表格
来完成。考虑以下数据文件:0 1
1 2
2 3
3 2
4 2
5 4
6 8
7 5
8 3
9 1
set samples 100
set table "table_100"
plot "data" smooth csplines
set samples 20
set table "table_20"
plot "data" smooth csplines
unset table
set samples
确定用于构建样条曲线的点数。您可以进行可视化:
set key left
plot "data" pt 7 t "Original data", \
"table_100" w l t "Splines (100 samples)", \
"table_20" w l t "Splines (20 samples)"
使用set table 'temp.dat'
将绘制的数据点重定向到外部文件。
set table 'temp.dat'
plot 'myfile.dat' using 1:2 smooth cspline
unset table
plot 'myfile.dat' using 1:2 with points title 'original points',\
'temp.dat' using 1:2 with lines title 'smoothed curve'