Reputation: 55
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!
Upvotes: 2
Views: 248
Reputation: 48390
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'
Upvotes: 3