2017-05-31 419 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