Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: 'Need full using spec for x time data'

Tags:

gnuplot

im a little bit new at gnuplot and i want to plot the evolution of COVID-19 in my country with x axis showing days instead of numbers.

Here is my data

#mm/dd  , Infect
03/06   , 1
03/09   , 3
03/11   , 9 
03/13   , 16
03/15   , 24
03/16   , 45
03/17   , 57
03/18   , 75
03/19   , 102
03/20   , 128
03/21   , 158
03/22   , 235
03/23   , 306
03/24   , 378
03/25   , 470

and heres my sript

set title 'COVID-19 En Colombia'
set ylabel 'Número de Personas'
set xlabel 'Día'
set xdata time
set timefmt '%m%d'
set format x '%m/%d'
set datafile sep ','
set key top left
set grid
set autoscale
set terminal png size 720,650
set output 'COVID19Col.png'
plot 'COVIDCol.dat' lt rgb 'red' w l title 'Infectados' using 1:3

but still telling me this

gnuplot> plot 'COVIDCol.dat' lt rgb 'red' w l title 'Infectados' using 1:3
         "covid.gp" line 25: Need full using spec for x time data 

I'd be very grateful for any help :3

like image 338
Felipe Reyes Avatar asked Jan 23 '26 15:01

Felipe Reyes


1 Answers

There are several issues here:

  1. The using keyword needs to follow the file name, and it should be using 1:2.
  2. You are missing the slash in the timefmt setting.
  3. You should add autotitle columnhead to the key setting.

With these changes it works:

plot.gp

set title 'COVID-19 En Colombia'
set ylabel 'Número de Personas'
set xlabel 'Día'
set xdata time
set timefmt '%m/%d'
set format x '%m/%d'
set datafile sep ','
set key top left autotitle columnheader
set grid
set autoscale
set terminal png size 720,650
set output 'COVID19Col.png'
plot 'COVIDCol.dat' using 1:2 lt rgb 'red' w l title 'Infectados'

Result: Plot of generated by the above script

like image 189
Thor Avatar answered Jan 26 '26 11:01

Thor