2016-08-12 308 views
12

我想要使用gnuplot來繪製以下兩個數據文件。gnuplot堆疊直方圖重疊

timings0.log:

41420 
32587 
4082 
4668 
81 
547 
325 

timings1.log:

41297 
32393 
4106 
4720 
75 
502 
266 

它們代表一個軟件,其中由執行所產生的每一個文件的不同部件的定時具有不同的配置,並且文件中的每一行對應於不同的組件。我正在使用sed命令能夠提取計時文件中的特定行(遵循建議here的方法),並且能夠顯示僅顯示某些組件的圖。我想在同一個圖中顯示兩組時間點,以堆積直方圖的方式顯示。

這裏是我當前的代碼:

set terminal svg size 500,500 enhanced font 'Times-Roman,14' 

set key vertical maxrows 3 

set style data histograms 
set style histogram rowstacked title offset 0,-1 gap 1 
set boxwidth 0.5 relative 
set style fill solid 1.0 

set xlabel offset 0,1 
set xrange [-1:2] 

set xtics 0,1 
set xtics add ("1st Config"0) 
set xtics add ("2nd Config"1) 
set xtics add (""2) 

set yrange [0:50000] 
set ylabel "Time (ms)" 
set ytics 0,5000,50000 

set output "test.svg" 

plot newhistogram "0" lt 1, "<(sed '2!d' timings0.log)" notitle, "<(sed '3!d' timings0.log)" notitle, "<(sed '4!d' timings0.log)" notitle, "<(sed '5!d' timings0.log)" notitle,\ 
    newhistogram "1" lt 1, "<(sed '2!d' timings1.log)" t "Load", "<(sed '3!d' timings1.log)" t "Sort", "<(sed '4!d' timings1.log)" t "Calculation", "<(sed '5!d' timings1.log)" t "Cleanup" 

代碼工作完美,當我只顯示一個柱狀圖(對應於timings0.log爲例),但在運行上面的腳本時同時顯示直方圖,他們未能展開在x軸上,他們似乎重疊。以下是上述腳本的輸出:

enter image description here

有可能是一個顯而易見的解決方案,但多次嘗試,並在網上提供了很多資源,搜索之後,我都未能獲得正確的輸出。我正在使用gnuplot 5 patchlevel 3.

在此先感謝,任何幫助將不勝感激!

回答

6

嘗試at

plot newhistogram at 0 lt 1, ... 
    newhistogram at 1 lt 1, ... 

我也得到一個錯誤與gap,至少在gnuplot的4.6。它對rowstacked沒有影響,但您可以在offset之前使用它。總體代碼:

set terminal svg size 500,500 enhanced font 'Times-Roman,14' 

set key vertical maxrows 3 

set style data histograms 
set style histogram rowstacked 
set boxwidth 0.5 relative 
set style fill solid 1.0 

set xlabel offset 0,1 
set xrange [-1:2] 

set xtics 0,1 
set xtics add ("1st Config"0) 
set xtics add ("2nd Config"1) 
set xtics add (""2) 

set yrange [0:50000] 
set ylabel "Time (ms)" 
set ytics 0,5000,50000 

set output "test.svg" 

plot newhistogram at 0 lt 1, "<(sed '2!d' timings0.log)" notitle, "<(sed '3!d' timings0.log)" notitle, "<(sed '4!d' timings0.log)" notitle, "<(sed '5!d' timings0.log)" notitle,\ 
    newhistogram at 1 lt 1, "<(sed '2!d' timings1.log)" t "Load", "<(sed '3!d' timings1.log)" t "Sort", "<(sed '4!d' timings1.log)" t "Calculation", "<(sed '5!d' timings1.log)" t "Cleanup" 

看起來這對我來說:

enter image description here

+0

謝謝,並獲得成功,幫助非常感謝! ;-) – Pyves