开发者

gnuplot plot discrete(?) time data

I should like to gnuplot some data for various devices, where the data is the time those devices开发者_如何学Go are in a certain state.

For example, given devices a to e, plot the time they go into alarm then exit, e.g. device a goes into alarm 11:00, out of alarm at 12:00, etc..

dev_a |   x------x
dev_b |     x-----x
dev_c | x-x
dev_d |           x-------------------
dev_e |     x-----x       x-----x
      |_______________________________
          |      |     |     |     |
        11:00  12:00 13:00 14:00 15:00

The input data would would need to be derived from logs similar to:

    ....
11:00 dev_a alarm on
    ....
11:00 dev_c alarm off
11:10 dev_b alarm on
    ....
12:00 dev_a alarm off
    ....

I am not really sure how to get started—a column plot of sorts?


To get started, you should adjust your input file to:

11:00 1 dev_a alarm on
11:01 3 dev_c alarm off
11:10 2 dev_b alarm on
12:00 1 dev_a alarm off
12:10 2 dev_b alarm on
11:15 4 dev_d alarm on
11:25 4 dev_d alarm off

then you use

set xdata time
set timefmt "%H:%M"
plot "file.txt" using 1:2:ytic(3) with points

You need the second column to put all entries of alarm a on 1 y axis label.

This will give you almost what you want. The only thing that is missing are the lines between the points. A possibility is to use arrows (without the head of the arrow so in fact it is a line) and build a script file in order to plot all arrows at once. Check out the answer of Tom with this question for a nice example: Plotting arrows with gnuplot


If you somehow manage to convert and split your log files into some format like this:

#time  dev_a
11:00   1
12:00   1
#time  dev_b
11:10  2
12:10  2

...

That is time format into floats, separate files per device, alarm on/off to const dev_id. Plotting becomes easy:

set style data linespoints
set yrange [0:5]
set xdata time
set timefmt "%H:%M"
plot "dev_a.data" using 1:2 title "dev_a", "dev_b.data" using 1:2 title "dev_b", ...

Ok, y-axis description is still an issue, but you can combine that with Martins answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜