Gábor DANI
Gábor DANI

Reputation: 2135

Gnuplot construct timefmt from different CSV columns?

I have the following csv file in which the columns represent hour,minute,view count respectively, exactly 1440 entries for every minute of the day. I would like to plot it using gnuplot. (Putting the HH:MM into one column is not possible due to the MySQL ONLY FULL GROUP BY.)

"0","0","71"
"0","1","55"
"0","2","56"
...
"23","57","66"
"23","58","70"
"23","59","75"

Currently I use the following commands:

set datafile separator ","
set timefmt "%H,%M"
set xdata time 
set xtics format "%H:%M" time font "/:normal,8" rotate by 45 offset -1,-1

The time format is not rendered correctly, the hours are interpreted as minutes and the minutes are not shown at all. I also tried set timefmt "\"%H\",\"%M\"" without success.

x plotting timestamps

Two questions:

Upvotes: 0

Views: 69

Answers (1)

Gavin Portwood
Gavin Portwood

Reputation: 1217

Use this time format string

set timefmt "%H:%M"

Put this function somewhere:

catdate(x,y)=sprintf("%d:%d",x,y) 

Then plot with:

plot 'data.dat' u (catdate($1,$2)):($3) w l

Upvotes: 1

Related Questions