如何让gnuplot读取我的时间格式并按输入文件的顺序保持时间? [英] How do I get gnuplot to read my time format and keep the times in order of the input file?

查看:101
本文介绍了如何让gnuplot读取我的时间格式并按输入文件的顺序保持时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让gnuplot能够(a)读取我的输入时间格式,并且(b)按照输入文件的顺序绘制时间.我正在尝试绘制过去24小时内从18 UTC开始的值更改.

I'm trying to get gnuplot to (a) read my input time format and (b) plot the time in order of the input file. I'm trying to plot changes to a value over the past 24 hours starting at 18 UTC.

它看起来不像:

set xdata time

set timefmt "%H%M"

它还喜欢绘制我的xaxis值(从0000 UTC到2300 UTC)并丢弃前导零.请参阅下面的输入文件.我希望最新的数据(在这种情况下为1800UTC)在我的xaxis的右侧.谢谢.

It also likes to plot my xaxis values from 0000 UTC to 2300 UTC and drops leading zeros. See below for input file. I would like the newest data (1800UTC in this case) to be on the right side of my xaxis. Thanks.

1900 23

2000 22

2100 22

2200 22

2300 22

0000 22

0100 22

0200 21

0300 21

0400 21

0500 21

以此类推...

推荐答案

Michael O.建议使用完整的日期以及年,月,日,这可能是处理主题最通用的方法. 但是,如果您不能或不想更改数据,则可以使用以下命令:

the suggestion from Michael O. to use a complete date with year, month, day is probably the most versatile way to handle your topic. However, if you cannot or don't want to change your data you could use the following:

解决方案1:当数据通过"0000"时,增加一天的时间(或86400秒)

Solution 1: add an extra day (or 86400 seconds) when data passes "0000"

解决方案2:将第一列用作字符串标签(只有在您的时间步长不变的情况下,x轴才会正确缩放).为了娱乐,我添加了仅显示部分标签的可能性.

Solution 2: use the first column as string label (x-axis will only be scaled correctly if your timesteps are constant). For fun, I added the possiblity to display only a part of the labels.

### time "without" date
reset session

$Data <<EOD
1900 23
2000 22
2100 22
2200 22
2300 22
0000 22
0100 22
0200 21
0300 21
0400 21
0500 21
EOD

set multiplot layout 2,1

    # solution 1: add extra day
    set xdata time
    set timefmt "%H%M"
    set format x "%H%M"
    extraday = 0
    plot $Data u ($1==0000 ? extraday = extraday + 1 : 0, timecolumn(1)+extraday*86400):2 w lp lt 7 lc rgb "red" title "add extra day"

    # solution 2: use timecolumn as xticlabel
    Modulo(x,n) = x - floor(x/n)*n
    plot $Data u 0:2:xticlabels(Modulo($1,200) == 0 ? stringcolumn(1) : "") w lp lt 7 lc rgb "green" title "timecolumn as xticlabel"

unset multiplot
### end of code

...将导致:

这篇关于如何让gnuplot读取我的时间格式并按输入文件的顺序保持时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆