change hour format gnuplot (substract 12 hour)

空扰寡人 提交于 2019-12-23 22:33:12

问题


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!


回答1:


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'


来源:https://stackoverflow.com/questions/32946517/change-hour-format-gnuplot-substract-12-hour

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!