Bashscript with Gnuplot on .csv and timespace

61 Views Asked by At

I am trying to extract a string from a csv capture. I am trying to plot labels on the graph.

these are the first few lines (variable amount):

Time,SecExec 
26/May/2022:00:08:07,0.666
26/May/2022:00:19:05,0.720
26/May/2022:00:20:33,0.965
26/May/2022:00:28:01,0.662
26/May/2022:00:28:38,1.090
26/May/2022:06:07:41,0.016
26/May/2022:06:09:07,1.194
26/May/2022:06:16:36,0.017
26/May/2022:06:36:37,0.743
26/May/2022:06:56:37,0.737
26/May/2022:07:09:16,0.006
26/May/2022:07:09:16,0.006
26/May/2022:07:10:55,0.009
26/May/2022:07:16:36,0.014
26/May/2022:07:16:39,0.008
26/May/2022:07:18:22,0.696

My execution code:

reset session

N1 = ARG1 #Title
N2 = ARG2 #File name

set datafile separator ','

set xdata time
set timefmt "%d/%m/%Y:%H:%M:%S"
set ylabel "Tiempo" font ",11"
set title N1 font ",14"
set format x "%d/%m/%Y:%H:%M:%S"
set xlabel "Fecha" font ",11"
set boxwidth 2.0 relative
set style fill solid 0.4
set grid x,y

set term png size 1200, 720
set output sprintf("numbers.png")

plot N2 u 1:2 w lp lw 1.5 lc 7

set output

My input in terminal:

gnuplot -c "codedata" "graphic-title" "archic.csv"

If I use this manual in the Gnuplot Terminal, it plots the desired data. The problem is that the execution leaves a range of invalid fields

1

There are 1 best solutions below

0
On

You are using the wrong time specifier. You should use %b or %B depending if you have abbreviated or full month names. Check help time_specifiers.

Script:

### plot time data with month name
reset session

$Data <<EOD
Time,SecExec 
26/May/2022:00:08:07,0.666
26/May/2022:00:19:05,0.720
26/May/2022:00:20:33,0.965
26/May/2022:00:28:01,0.662
26/May/2022:00:28:38,1.090
26/May/2022:06:07:41,0.016
26/May/2022:06:09:07,1.194
26/May/2022:06:16:36,0.017
26/May/2022:06:36:37,0.743
26/May/2022:06:56:37,0.737
26/May/2022:07:09:16,0.006
26/May/2022:07:09:16,0.006
26/May/2022:07:10:55,0.009
26/May/2022:07:16:36,0.014
26/May/2022:07:16:39,0.008
26/May/2022:07:18:22,0.696
EOD

set datafile separator ','
set xdata time
set timefmt "%d/%b/%Y:%H:%M:%S"
set xlabel "Fecha" font ",11"
set format x "%b %d\n%H:%M"
set ylabel "Tiempo" font ",11"
set grid x,y

plot $Data u 1:2 w lp lw 1.5 lc 7
### end of script

Result:

enter image description here