2015-05-24 135 views
2

根據這個問題Gnuplot smooth confidence interval lines as opposed to error bars我能夠獲得通過給我的數據相同的結果給出了答案(y的誤差是對稱的,因此它是y加/減errorY):gnuplot的光滑置信帶

# 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點給出。如果連接不僅僅是一條直線,而且還有一條平滑線,比如說如何用數據點平滑數據點。

回答

4

這是一個棘手的問題,因爲平滑只適用於單列,並不能直接與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' 

enter image description here