I have csv data with timestamp like this:
2019-01-04-11:01:31,1.593
2019-01-04-11:01:33,1.592
2019-01-04-11:01:36,1.593
2019-01-04-11:01:38,1.593
I currently print data so:
set xdata time
set timefmt "%Y-%m-%d-%H:%M:%S"
set format x "%H:%M"
plot 'data.csv' using 1:2 w lines lw 1
That prints the time on x from start to end time in 24h format. But how can I format x as elapsed time from start time in minutes or hours so the example data would give 0 2 5 7 seconds in this case, or minutes/hours with other data?
try the following:
### Time difference
reset session
$Data <<EOD
2019-01-04-11:01:31,1.593
2019-01-04-11:01:33,1.592
2019-01-04-11:01:36,1.593
2019-01-04-11:01:38,1.593
2019-01-05-00:05:00,1.590
2019-01-06-00:06:00,1.591
2019-01-07-00:07:00,1.592
EOD
set datafile separator ","
set xdata time
MyTimeFormat = "%Y-%m-%d-%H:%M:%S"
set timefmt MyTimeFormat
set format x "%tH:%tM"
set multiplot layout 2,1
# Solution 1: StartTime hardcoded
StartTime = strptime(MyTimeFormat,"2019-01-04-11:01:31")
plot $Data u ((timecolumn(1)-StartTime)):2 w lp pt 7 lc rgb "red"
# Solution 2: Take first line automatically as StartTime
set table $Dummy
plot $Data u 0:(AutoStartTime = timecolumn(1,MyTimeFormat)) every ::0::0 with table
unset table
plot $Data u ((timecolumn(1)-AutoStartTime)):2 w lp pt 7 lc rgb "blue"
unset multiplot
### end of code