ner*_*zle 3 gnuplot curve-fitting
根据这个问题给出的答案,Gnuplot平滑置信区间线而不是误差条我能够得到相同的结果给出我的数据(y的误差是对称的所以它是y加/减errorY):
# x y errorY
1 3 0.6
2 5 0.4
3 4 0.2
4 3.5 0.3
Run Code Online (Sandbox Code Playgroud)
码:
set style fill transparent solid 0.2 noborder
plot 'data.dat' using 1:($2-$3):($2+$3) with filledcurves title '95% confidence', \
'' using 1:2 with lp lt 1 pt 7 ps 1.5 lw 3 title 'mean value'
Run Code Online (Sandbox Code Playgroud)
现在通过连接每个y + errorY和y-errorY点给出置信带.如果连接不仅仅是一条直线,而是一条平滑的线条,就像人们如何使数据点平滑一样,我想要它smooth csplines.
这有点棘手,因为平滑仅适用于单个列,并且不能直接与filledcurves绘图样式组合.
因此,您必须首先生成两个临时数据文件,方法是将平滑的上限和下限置信边界绘制为单独的数据文件
set table 'lower.dat'
plot 'data.dat' using 1:($2-$3) smooth cspline
set table 'upper.dat'
plot 'data.dat' using 1:($2+$3) smooth cspline
unset table
Run Code Online (Sandbox Code Playgroud)
然后paste lower.data upper.dat在绘制数据之前将这两个文件组合起来.如果您没有paste命令行程序,还可以使用任何其他脚本paste.py来合并文件:
set terminal pngcairo
set output 'data.png'
set style fill transparent solid 0.2 noborder
plot '< paste lower.dat upper.dat' using 1:2:5 with filledcurves title '95% confidence', \
'data.dat' using 1:2 with lines lt 1 smooth cspline title 'mean value',\
'' using 1:2 with points lt 1 pt 7 ps 1.5 lw 3 title 'data points'
Run Code Online (Sandbox Code Playgroud)
