Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gnuplot Date and Time on the x axis

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 0

This 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

like image 293
user3863950 Avatar asked Aug 01 '14 08:08

user3863950


1 Answers

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
like image 128
Christoph Avatar answered Oct 13 '22 07:10

Christoph