更改小时格式gnuplot(减12小时) [英] change hour format gnuplot (substract 12 hour)
问题描述
我试图应用这个解决方案:
如何在gnuplot中读取12h(AM / PM)时间格式
这样:我的数据是这样的:
#时间浓度(#/cm³)
05:00:14 5902
05:00:15 5898
05:00:16 5989
05:00:17 5921
我正在运行下面的代码:
pre code $ set $ d $ time $ $ $ $ b set format x'%H:%M'
set xlabeltime
plot< awk'{time = $ 1; if substr(time,1,2) = 12)add = 12; else add = 0}'data1.txtu 1:2 t'CPC1'wl,\
data2.txtu 1:2 t'CPC2'wl
暂停-1
然而,被处理的data1文件没有被绘制, data2具有正确的时间表。任何想法的解决方案?
在此先感谢您!
可以在gnuplot里直接加上12个小时。在内使用
语句使用 timecolumn
来获得以秒为单位的时间,然后添加12小时(43200秒) p>
set xdata time $ b $ set timefmt'%H:%M:%S'
set format x'% H:%M'
设置xlabeltime
设置样式数据行
使用(timecolumn(1)+ 43200)绘制'data1.txt':2'CPC1 ',\
'data2.txt'using 1:2 t'CPC2'
I have two devices working in paralell, the problem is that one of them was set up 12 hours different than the other (that is, instead of 17:00, marked 05:00). I'm trying to apply this solution: How to read 12h (AM/PM) timeformat in gnuplot
In this way: My data are like this:
#Time Concentration (#/cm³)
05:00:14 5902
05:00:15 5898
05:00:16 5989
05:00:17 5921
And I'm running the folowing code:
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
However, the treated data1 file is not being plotted, only the data2 which has the correct timescale. Any idea of solution?
Thanks in advance!
You can add the 12 hours directly inside gnuplot. Inside the using
statement use timecolumn
to get the time in seconds and then add your 12 hours (43200 seconds)
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'
这篇关于更改小时格式gnuplot(减12小时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!