2017-05-31 82 views
1

我希望顯示在從沿時間線的多個源一定時間戳給出的數據。例如,與follwing到輸入文件與柱1爲時間戳和列2的數據:對齊時間戳值到時間軸

O1.dat:

100 5 
300 10 

O2.dat:

200 7 
400 3 

隨着該所有值的平均值以一定間隔進行採樣:

Avg.dat:

250 6.5 
500 6.25 

我想繪製的所有值在表狀的方式,所以它看起來是這樣的,與價值觀相一致,以頂部的時間:

enter image description here

我的真實數據達到的時間戳高達10000,所以動態會很好。

到目前爲止,我只簡單的繪製框或線圖,所以我不知道如何去這一個。

謝謝你的時間。

編輯:

這是什麼樣子至今一起接受的答案做了調整:

enter image description here

仍然有一些重疊的,但那是因爲該數據是簡單地彼此太靠近了。用於此腳本:

#set term pdf 
#set term pdf size 8, 5 
#set output 'out.pdf' 
set term png 
set term png size 1200, 700 
set output 'out.png' 

set termoption font ",20" 
set label 'Time (ms)' at graph 0, graph 1 offset -0.75, char 1 right 
unset border 
unset key 
unset xtics 
set ytics scale 0 
set x2tics() scale 0 
set yrange [0:5.5] 
set x2range[0:10000] 
set lmargin 9 

set arrow from graph -0.15, graph 1 to graph 1.1, graph 1 nohead 
set arrow from graph -0.01, graph 1.2 to graph -0.01, graph -0.2 nohead 
set arrow from graph -0.15, first 0.3 to graph 1.1, first 0.3 nohead 

set style data labels 
plot for [i=0:9] 'desc'.i.'.txt' using 1:(5-0.5*i):(sprintf('%d', $2)):ytic('Object '.i) axes x2y1, \ 
    'Avg.dat' using 1:(0):(sprintf('%d', $2)):ytic('Avg') axes x2y1 

回答

2

傳統的,簡單的部分繪製的實際數據。爲此,您可以使用labels繪圖風格。一個非常簡單的例子是:

set xtics (0) 
set xrange [0:*] 
set offsets graph 0, graph 0.2, graph 0.2, graph 0.2 
set style data labels 
unset key 
plot 'O1.dat' using 1:(5):(gprintf('%g', $2)):ytic('O1'),\ 
    'O2.dat' using 1:(4):(gprintf('%g', $2)):ytic('O2'),\ 
    'Avg.dat' using 1:(3):(gprintf('%g', $2)):ytic('Avg'):xtic(1) 

,簡單地從你的數據文件繪製的值在第一列給出的X位置標籤。在Y位置被設置爲固定號碼:

enter image description here

爲了將XTICK標籤移動到頂部,並有你需要多一點的調整一些表樣系:

reset 

set termoption font ",20" 
set label 'Object' at graph 0, graph 1 offset -1, char 1 right 
unset border 
unset key 
unset xtics 
set ytics scale 0 
set x2tics() scale 0 format "%g" 
set yrange [2:5.5] 
set x2range[0:*] 
set lmargin 8 

set arrow from graph -0.15, graph 1 to graph 1.1, graph 1 nohead 
set arrow from graph 0, graph 1.2 to graph 0, graph 0 nohead 
set arrow from graph -0.15, first 3.25 to graph 1.1, first 3.25 nohead 

set style data labels 
plot 'O1.dat' using 1:(5):(sprintf('%d', $2)):ytic('O1') axes x2y1,\ 
    'O2.dat' using 1:(4):(sprintf('%d', $2)):ytic('O2') axes x2y1,\ 
    'Avg.dat' using 1:(2.5):(gprintf('%g', $2)):ytic('Avg'):x2tic(1) axes x2y1 

這樣的表格佈局是不是一個典型的任務,所以你必須適應多種設置,以您的最終結果。主要影響來自畫布大小,字體和字體大小。

enter image description here

如果你有比這兩個文件越多,你當然也可以遍歷一個文件列表。

+0

這點上,非常感謝你。我用當前的結果編輯了我的問題。還有一些調整要做,但看起來不錯。 – BananaBuster