更改小时格式gnuplot(减法12小时)

时间:2015-10-05 10:37:01

标签: time format gnuplot

我有两个设备工作在并行,问题是其中一个设置了12个小时不同于另一个(即,而不是17:00,标记为05:00)。 我正在尝试应用此解决方案: How to read 12h (AM/PM) timeformat in gnuplot

这样:我的数据是这样的:

#Time   Concentration (#/cm³)   
05:00:14    5902    
05:00:15    5898    
05:00:16    5989    
05:00:17    5921    

我正在运行下面的代码:

set xdata time
set timefmt '%H:%M:%S'
set format x '%H:%M'  
set xlabel "time"

plot  "< awk '{time = $1; if substr(time,1,2) <= 12) add = 12; else add = 0}' data1.txt" u 1:2 t 'CPC1' w l, \
      "data2.txt" u 1:2 t 'CPC2' w l

pause -1

但是,未处理处理的data1文件,仅绘制具有正确时间刻度的data2。有什么解决方案吗?

提前致谢!

1 个答案:

答案 0 :(得分:2)

您可以直接在gnuplot中添加12小时。在using语句中使用timecolumn以秒为单位获取时间,然后再添加12小时(43200秒)

set xdata time
set timefmt '%H:%M:%S'
set format x '%H:%M'  
set xlabel "time"
set style data lines

plot 'data1.txt' using (timecolumn(1) + 43200):2 t 'CPC1',\
     'data2.txt' using 1:2 t 'CPC2'