1
votes

I'm trying to create a simple histogram of events per month over a 12 month year in Gnuplot. There are no events in either bin 2 or bin 7 and rather than plotting those bins as 0 it extends the neighboring bins over this space. I am using the following histogram plotting routine, which I've gotten from here: http://gnuplot-surprising.blogspot.com.au/2011/09/statistic-analysis-and-histogram.html

max=12
min=1
binwidth=1
hist(x,width)=x
set style fill solid 0.5
set xrange[0.5:12.5]
plot "file" using (hist($4,binwidth)):(1.0) smooth freq w boxes lc rgb"green"

where a sample row from "file" looks like this:

2008-11-21-08:10:47 29455.0 2008 11 21 19:10:47

The fourth column is the month information I am trying to plot. The resulting histogram is at the link:

https://docs.google.com/drawings/d/12yFs_KIznhrMx62OIwJJFVmlnwIk4TXdHSdGc0yWqwI/edit?usp=sharing

The bins centered on 2 and 7 (that should be 0) are missing and the neighboring bins are extended instead. I'm not sure where my error is and would appreciate any help! Thank you!

1

1 Answers

2
votes

You should consult the gnuplot documentation about the boxes plotting style. Use

set boxwidth 1

otherwise the width of each box is caculated automatically so that it touches the adjacent boxes.