2
votes

I'm trying to plot a histogram with the xtics as time information. The gp script I'm using is this one:

set style data histogram
set style histogram cluster gap 1
set boxwidth 1

set datafile separator "\t"
set yrange[0:3000]
set xlabel "xaxis"
set ylabel "yaxis"
set xdata time
set timefmt "%Y-%m-%d %H"


set terminal png size 1200,800
set output outputfile
plot inputfile u 2:1 title "Count"

An example of my inputfile(that I pass by parameter) is this one:

2012-07-22 00:00:00    159.361111111
2012-07-22 01:00:00    207.019166667
2012-07-22 02:00:00    191.749722222
2012-07-22 03:00:00    147.647777778
2012-07-22 04:00:00    107.751388889
2012-07-22 05:00:00    95.9566666667
2012-07-22 06:00:00    110.405277778
2012-07-22 07:00:00    151.689166667
2012-07-22 08:00:00    244.787777778
2012-07-22 09:00:00    481.601388889

However I'm receiving the error "plot_timeflow.gp", line 16: Too many columns in using specification and when I try to set the plot command to plot inputfile u 2:xticlabels(1) title "Count" I have the following error: "plot_timeflow.gp", line 16: Need full using spec for x time data.

Does someone have any ideia, what is the problem??

Thanks in advance.

1

1 Answers

3
votes

Strange indeed. But in any case, for your data the boxes plotting style is better, because with histograms, every box has an own xtic. With boxes, the x-axis is treated as a normal time axis:

set boxwidth 0.8 relative
set datafile separator "\t"
set yrange[0:3000]
set xlabel "xaxis"
set ylabel "yaxis"
set xdata time
set timefmt "%Y-%m-%d %H"

set style fill solid

plot 'data.txt' using 1:2 with boxes title "Count"

That gives:

enter image description here