x range is invalid GNUplot time and date
If you have access to commandline tool like grep
you can filter your datafile before plotting it:
set datafile sep ','
set xdata time
set timefmt '%d/%m/%Y,%H:%M:%S'
#DATA FILES
plot '< grep -E ''^[0-9]{8,}'' PAS.csv' using 2:4 title 'Passive' with points pt 5 lc rgb 'red'
This removes all lines which don't start with at least eight digits. Tested to work with 4.6.3.
Alternatively, if an older gnuplot version has a problem with the comma inside the timefmt
, you can also use the timestamp in the first column for your x-axis:
set datafile sep ','
set xdata time
set timefmt '%s'
plot '< grep -E ''^[0-9]{8,}'' PAS.csv' using 1:4 title 'Passive' with points pt 5 lc rgb 'red'
Admin
Updated on June 04, 2022Comments
-
Admin almost 2 years
I am trying to plot data that I get from dataloggers, and I am not sure why I get an xrange is invalid error.
Below is my minimal script and a sample of the data I am trying to plot. They all have similar headers which i thought was the problem, but I tried #commenting them out or deleting them and that didn't work. If the solution could include a way for me to do this without messing with the headers, that would be great and save me a lot of time.
I've changed the headers to just the letter A for data protection, it gives the same error.
Min Code
#!/gnuplot set datafile sep ',' set xdata time set timefmt '%d/%m/%Y,%H:%M:%S' #DATA FILES plot 'PAS.csv' using 2:4 title 'Passive' with points pt 5 lc rgb 'red' axes x1y1,\ 'ACT.csv' using 2:4 title 'Active' with points pt 5 lc rgb 'blue' axes x1y1,\ 'RISK.csv' using 2:4 title 'Risk' with points pt 5 lc rgb 'black' axes x1y2
DATA
AAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA Timestamp,Date,Time,Value,Units 1415879007,13/11/2014,11:43:27,0.011,µA 1415878407,13/11/2014,11:33:27,0.045,µA 1415877807,13/11/2014,11:23:27,0.003,µA 1415877207,13/11/2014,11:13:27,0.056,µA 1415876607,13/11/2014,11:03:27,-0.036,µA 1415876007,13/11/2014,10:53:27,-0.046,µA 1415875407,13/11/2014,10:43:27,-0.039,µA 1415874807,13/11/2014,10:33:27,-0.050,µA 1415874207,13/11/2014,10:23:27,0.051,µA 1415873607,13/11/2014,10:13:27,-0.014,µA 1415873007,13/11/2014,10:03:27,0.035,µA 1415872407,13/11/2014,09:53:27,0.054,µA 1415871807,13/11/2014,09:43:27,-0.006,µA 1415871207,13/11/2014,09:33:27,-0.049,µA 1415870607,13/11/2014,09:23:27,0.000,µA 1415870007,13/11/2014,09:13:27,0.048,µA 1415869407,13/11/2014,09:03:27,-0.029,µA
Thank you!