can gnuplot可以從原始數據文件創建boxplot?我知道如何從已經計算好的中位數,四分位數等like this中繪製箱形圖 - 但是如何從原始數據文件?gnuplot:從原始數據創建boxplot
在原始數據文件的每一行中都有一個測試結果。
can gnuplot可以從原始數據文件創建boxplot?我知道如何從已經計算好的中位數,四分位數等like this中繪製箱形圖 - 但是如何從原始數據文件?gnuplot:從原始數據創建boxplot
在原始數據文件的每一行中都有一個測試結果。
如果我正確理解你的問題,你正在尋找一種方式來計算平均值,你可以做這樣的事情:
calc_mean(x1,x2,x3) = (x1+x2+x3)/3
calc_sum(x1,x2,x3) = x1+x2+x3
get_min(x1,x2,x3) = x1 < x2 ? (x1 < x3 ? x1 : (x2 < x3 ? x2 : x3)) : (x2 < x3 ? x2 : x3)
get_max(x1,x2,x3) = x1 > x2 ? (x1 > x3 ? x1 : (x2 > x3 ? x2 : x3)) : (x2 > x3 ? x2 : x3)
plot "Data.csv" u 0:(calc_mean($1, $2, $3)) t "Mean" w l, \
"" u 0:(calc_sum($1, $2, $3)) t "Sum" w l, \
"" u 0:(get_min($1, $2, $3)) t "Min" w l, \
"" u 0:(get_max($1, $2, $3)) t "Max" w l
上面的腳本計算平均值,總和,最小和數據線的最大值。 using指令中的0
只是將數據行的索引作爲x座標值。
用下面Data.csv
:
0.62614 0.50293 0.62078
0.63789 0.58924 0.71288
0.16297 0.77453 0.82417
0.20703 0.22424 0.33596
0.57829 0.96545 0.60737
您將獲得以下情節:
我希望這是你所期待的。
我想你必須最終使用外部程序來計算box plot的必要數據。我用過awk,但任何程序都可以在這個地方使用。請注意,我計算了每行原始數據中的開/關/最小/最大值,而不是均值和分位數。
set xrange [-1:9]
plot "< awk '{sum=0; opening=$1; closing=$NF; min=$1; max=$1; \
for (i=1; i<=NF; i++) {sum=sum+$i; if ($i<min) min=$i; if ($i>max) max=$i}; \
print sum/NF, opening, closing, min, max}' \
junk.dat" us 0:2:4:5:3 w candle notitle
隨着junk.dat
文件中的以下數據:
5.532 5.040 4.962 19.314 5.136
10.004 4.592 5.836 6.999 7.823
8.887 6.335 5.545 5.056 6.216
4.341 4.552 4.512 4.009 5.811
4.724 4.869 5.016 2.593 5.662
4.555 5.472 4.866 5.559 -0.608
6.974 3.838 2.953 6.630 2.753
5.571 8.112 3.261 7.029 4.375
3.497 5.200 6.555 5.311 8.204
這裏的劇情,你會得到:
過這個剛剛來到自己,在gnuplot的4.5(CVS目前的開發版)它有這個功能。
目前,這意味着你必須從源碼http://gnuplot.sourceforge.net/development/index.html#DownloadCVS自己編譯gnuplot。
一旦你完成了,下面是一個演示文件:http://gnuplot.sourceforge.net/demo_4.5/boxplot.html