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
Code:
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'
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
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With