(Because some of you might possibly request the script, here it is:
set boxwidth 0.75 absolute
set style fill solid 1.00 border -1
set style data histogram
set style histogram cluster gap 1
set xtics nomirror out rotate by -30;
set title "Daily number of packages received from node \n \
during 18.11.2009 - 18.1.2009"
plot "ready/count" using 2:xtic(1) t '1978', \
"ready/count" using 3 t '2473'
)
> Gnuplot does not automaticly limit the amount of xticlabels in
> histograms like it does with other plotting types.
> To illustrate the problem:
> http://shiona.ath.cx/count.png
> I guess there are 61 xtics, maybe one of five could be ok.
> Any help appreciated.
The form xtic(1) is shorthand for xtic(stringcolumn(1)).
That is, xtic(foo) really expects a function foo that returns a string.
The command xtic(1) is doing exactly what you asked, which is to
place an tic label for every entry in column 1. So you need to do
something slightly different. The basic idea should be evident
from this command:
everyfifth(col) = (int(column(col) % 5 == 0) ? "A" : ""
plot 'data' using 1:2:(everyfifth(0))
The function everyfifth(0) returns a string value for each point
in the data set. Column 0 by convention holds the index of that
point within the data set. The string is set to "A" for every
5th point, and "" otherwise.
But you don't want "A". You want the contents of column 1,
treated as a string. So we change this to
everyfifth(col) = (int(column(col)) % 5 == 0) ? stringcolumn(1) : "")
Ethan
Hi,
I have incorprated this solution into my gnuplot script. But it
failed to generate histogram graph.
Could someone help me? Thanks.
My Data file (hist.txt):
bin distibution
0.100000 0.000000
0.200000 0.003273
0.300000 0.000818
0.400000 0.000818
0.500000 0.001637
0.600000 0.004092
0.700000 0.000818
0.800000 0.001637
0.900000 0.000818
1.000000 0.001637
1.100000 0.000000
1.200000 0.000000
1.300000 0.001637
1.400000 0.000818
1.500000 0.000818
1.600000 0.000818
1.700000 0.001637
1.800000 0.000000
1.900000 0.000000
2.000000 0.004910
2.100000 0.007365
My Gnuplot Script (bin_hist_gp.txt):
set xlabel "Bin Size "
set ylabel "Density "
unset key
set size 1.0, 1.0
set origin 0.0, 0.0
set style data histogram
set style histogram cluster gap 1
set style fill solid border -1
set boxwidth 0.75
set t png size 400,300
everytenth(col) = (int(column(col))%10 ==0)?stringcolumn(1):""
plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
set output
exit
And the final output message after it is executed in gnuplot.
"
gnuplot bin_hist_gp.txt
plot "hist.txt" u 2:(everytenth(0)) title "Distribution"
^
"bin_hist_gp.txt", line 12: Too many columns in using specification
"
And when I replace the code 'plot "hist.txt" u 2:(everytenth(0)) title
"Distribution" ' as ' plot "hist.txt" u 2:xticlabels(everytenth(0))
title "Distribution" '. It failed with unrecognized message. I
have no idea about the real issue.