I'm having trouble with the boxwidth option in gnuplot when trying to plot a histogramm. Here is the gnuplot script I use to plot the histogram of random numbers normally distributed:
# Parameters
n=50 # number of intervals
min=-5. # min value
max=5. # max value
width = (max-min)/n # interval width
# Function used to map a value to the intervals
hist(x,width)=width*floor(x/width)+width/2.
# Output
set term png
set output "histogram.png"
# Graph
set xrange [min:max]
set yrange [0:]
set xtics min,(max-min)/5,max
set boxwidth width*0.9
set style fill solid 0.5
set tics out
set yzeroaxis # Add a vertical dotted line at x=0 to show centre (mean) of distribution
set xlabel "Random number"
set ylabel "Frenquency (%)"
# Count and Plot
plot "Random_numbers.txt" u (hist($1,width)):(100.0/ 10000 ) smooth freq w boxes notitle
With this script, the "boxes" are just "lines" (boxes with no width). Do you know why ?
When I remove the line "set boxwidth width*0.9", it works except that the boxes width is "width" (the boxes are touching the adjacent boxes).
Many thanks in advance !
NB : Sorry the image uploading is not working, I hope you can imagine my problem (I want to get a plot like this:
but in my case the boxes have no width, they are just vertical lines) ...