1
votes

I have a data file with the following columns:

Year:Month    Data1    Data2   Data3

For a given range of dates (say, the last year), I would like to plot using boxes so at each month there are 3 boxes side by side (each 1/3 a full month width), one each for Data1, Data2 and Data3. But I can't make gnuplot play. Here's what I've tried:

set xdata time
set timefmt "%Y:%m"
set style fill solid
set boxwidth 890000 absolute # Third of a month in seconds, approx
plot ["2020:02" : "2021:02"][0:] "file.dat" using 1:2 with boxes, "file.dat" using ($1 - 890000):3 with boxes, "file.dat" using ($1 + 890000):4 with boxes

I fear I'm misunderstanding the difference between "using 1:2" and "using ($1 + ...):2", but not sure how - the resulting plot has the correct Y scale/values, but the X scale is all over the place.

1

1 Answers

1
votes

The using ($1) does not respect the time format. Try using (timecolumn(1, "%Y:%m")) instead.

plot ["2020:02" : "2021:02"][0:] "file.dat" using 1:2 with boxes, \
                                 "file.dat" using (timecolumn(1, "%Y:%m")-890000):3 with boxes, \
                                 "file.dat" using (timecolumn(1, "%Y:%m")+890000):4 with boxes