问题描述
根据此问题给出的答案对于以下给出的数据,我可以获得相同的结果(y的误差是对称的,因此它是y的正负误差Y) :
According to the answer given in this question Gnuplot smooth confidence interval lines as opposed to error bars I was able to get the same result for my data given by (the error of y is symmetric so it is y plus/minus errorY):
# 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
平滑数据点。.
Now the confidence band is given by connecting every y+errorY and y-errorY point. I would like it if the connection is not just a straight line, but rather a smooth line, like how one can smoothen data points with smooth csplines
..
推荐答案
这有点棘手,因为平滑仅在单个列上起作用,并且不能与直接结合使用
That is a bit tricky, because smoothing works only on a single column, and can't be directly combined with the filledcurves
plotting style.
因此,必须首先通过绘制平滑的上下置信度边界来生成两个临时数据文件,以使用
So you must first generate two temporary data files by plotting the smoothed upper and lower confidence boundaries to separate data files with
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
然后将这两个文件与粘贴在一起,粘贴
,然后再绘制数据。如果您没有
lower.data upper.dat 粘贴
命令行程序,则还可以使用任何其他脚本,例如来合并文件:
And then combining those two files with paste lower.data upper.dat
before plotting the data. If you don't have the paste
command line program, you can also use any other script like paste.py
to merge the files:
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'
这篇关于Gnuplot平滑置信带的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!