【问题标题】:Gnuplot smooth confidence bandGnuplot 平滑置信带
【发布时间】:2015-08-06 06:56:18
【问题描述】:

根据这个问题Gnuplot smooth confidence interval lines as opposed to error bars 中给出的答案,我能够得到与给出的数据相同的结果(y 的误差是对称的,所以它是 y 加/减误差 Y):

# x y errorY   
1   3   0.6 
2   5   0.4  
3   4   0.2
4   3.5 0.3

代码:

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'

现在通过连接每个 y+errorY 和 y-errorY 点给出置信带。如果连接不仅仅是一条直线,而是一条平滑线,我希望它是一条平滑线,例如如何使用 smooth csplines.. 平滑数据点。

【问题讨论】:

    标签: gnuplot curve-fitting


    【解决方案1】:

    这有点棘手,因为平滑只适用于单列,不能直接与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
    

    然后在绘制数据之前将这两个文件与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'
    

    【讨论】:

      猜你喜欢
      • 2014-10-20
      • 2016-05-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-18
      • 1970-01-01
      • 1970-01-01
      • 2021-06-15
      相关资源
      最近更新 更多