Gnuplot Date and Time on the x axis
Such an error is triggered, if some unexpected data appears in the data file, like an uncomment and unused header line in your case.
The following file.dat
Date Time Value
30/07/2014 00:59:38 0.075
30/07/2014 00:58:34 0.102
gives such an error with the minimal script
set xdata time
set timefmt '%d/%m/%Y %H:%M:%S'
plot 'file.dat' using 1:3
To solve the error, remove the first line (or similar lines in between).
Since version 4.6.6 you could also use the skip
option to skip some lines at the beginning of the data file like:
set xdata time
set timefmt '%d/%m/%Y %H:%M:%S'
plot 'file.dat' using 1:3 skip 1
user3863950
Updated on July 02, 2022Comments
-
user3863950 almost 2 years
What I want to do is plot a graph where my x axis takes a date from the first column of data and then a time from my second column and uses both to create the x axis,
I have a set of data from a date logger that I want to graph on gnuplot, as I get new data every day and it would be so easy to just add on each txt file as I get them
The text files look like this (each span 24 hours)
Date Time Value
30/07/2014 00:59:38 0.075
30/07/2014 00:58:34 0.102
30/07/2014 00:57:31 0.058
30/07/2014 00:56:31 0.089
30/07/2014 00:55:28 0.119
30/07/2014 00:54:26 0.151
30/07/2014 00:53:22 0.17
30/07/2014 00:52:19 0.171
30/07/2014 00:51:17 0.221
30/07/2014 00:50:17 0
30/07/2014 00:49:13 0
30/07/2014 00:48:11 0
30/07/2014 00:47:09 0This solution mixing date and time on gnuplot xaxis would suit me perfectly, but its very complex and I have no idea what is going on, let alone apply it to multiple files
Here's the code I tried, but I get an illegal day of the month error?
#!/gnuplot set timefmt '%d/%m/%Y %H:%M:%S' set xdata time set format x '%d/%m/%Y %H:%M:%S' #DATA FILES plot '30.07.2014 Soli.txt' using 1:3 title '30/07/2014' with points pt 5 lc rgb 'red',\ '31.07.2014 Soli.txt' using 1:3 title '31/07/2014' with points pt 5 lc rgb 'blue'
All help appreciated! Thanks
-
Christoph over 9 yearsWell, the second option isn't really an option because the OP has a separate title to show. And the first option is already what my answer says... So what's your point?
-
user3863950 over 9 yearsThe headers weren't the problem, the problem was the footer left by the data logger I was using (100000 points down hence why i didnt see it), once i deleted the bit at the bottom, it worked fine
-
Alejandro Galera over 9 yearsChristoph, my point is use "title columnhead" with your code or use an input file without titles with your gnuplot script. Maybe you could have choosen columnhead to avoid unreadable file error
-
mtk over 8 yearshow to give the column number dynamically e.g. in your case how can i put column 1 and 3 in a variable for
1:3
. Please check my question on this here stackoverflow.com/questions/32811596/…