Gnuplot multiple lines with time on the x axis

I looked through the questions, but still can't get it to work.

My dataset is as follows:

[date] , [%cpu] , [mem] 23:00:39 , 21.9 , 2.1 23:00:44 , 21.8 , 2.1 23:00:49 , 21.8 , 2.1 23:00:54 , 21.8 , 2.1 23:00:59 , 21.7 , 2.1 

My Gnuplot statements (just started using for this data):

 set timefmt "%H:%m:%s" set xdata time set datafile sep ',' plot '/tmp/info' using 2 title 'cpu' with lines, '/tmp/info' using 3 title 'memory%' with lines 

I get the following error:

  Need full using spec for x time data 

I tried autoscaling x, but I'm a bit lost, any help would be appreciated.

+8
gnuplot
source share
3 answers

Time data requires that you always specify all columns used. (Note also the adjusted timefmt ):

 set timefmt "%H:%M:%S" set xdata time set datafile sep ',' set style data lines plot '/tmp/info' using 1:2 title 'cpu', '' using 1:3 title 'memory%' 

The reason for this is that timefmt may also contain spaces, so the data used for the time axis can come from two columns. Consider the following modified data file:

 23:00:39 06/08/13 21.9 2.1 23:00:44 06/08/13 21.8 2.1 23:00:49 06/08/13 21.8 2.1 23:00:54 06/08/13 21.8 2.1 23:00:59 06/08/13 21.7 2.1 

Build commands for this format:

 set timefmt "%H:%M:%S %d/%m/%Y" set xdata time set format x "%H:%M:%S" set style data lines plot 'mydata.dat' using 1:3 t 'cpu', '' using 1:4 t 'memory%' 

To avoid confusion, it is always required that, for time data, all columns used by the build style (here with lines ) are explicitly specified using the using statement.

+5
source share

Instead, your command looks like this:

 plot '/tmp/info' using 1:2 title 'cpu' with lines, '/tmp/info' using 1:3 title 'memory%' with lines 
+2
source share

I had a similar problem with gnuplot, where I had a data file like:

 05:07:00 0.0769 0.0769 0.0000 0.0000 0.0000 0.0000 0.0000 05:08:00 0.2308 0.2308 0.0000 0.0000 0.0000 0.0000 0.0000 

I tried to use, but it just didn't work

 set xdata time set timefmt "HH:MM:SS"; plot "wed" using 0:2 t 'wtf" w lines 

The fix was a few things, mostly using% in the timefmt line and only one letter. Also, using the key format for the output was key (and using the first column as 1 - although I tried this also before).

This is the minimal output script that works for me:

 set xdata time set timefmt "%H:%M:%S" set format x "%H:%M" plot "wed" using 1:2 t 'my title' w lines 
0
source share

All Articles