GNU Scientific Library Reference Manual  Third Edition (v1.12) by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) 
21.13 The 2D histogram struct
Two dimensional histograms are defined by the following struct,
 Data Type: gsl_histogram2d
size_t nx, ny
 This is the number of histogram bins in the x and y directions.
double * xrange
 The ranges of the bins in the xdirection are stored in an array of nx + 1 elements pointed to by xrange.
double * yrange
 The ranges of the bins in the ydirection are stored in an array of ny + 1 elements pointed to by yrange.
double * bin

The counts for each bin are stored in an array pointed to by bin.
The bins are floatingpoint numbers, so you can increment them by
noninteger values if necessary. The array bin stores the two
dimensional array of bins in a single block of memory according to the
mapping
bin(i,j)
=bin[i * ny + j]
.
The range for bin(i,j)
is given by xrange[i]
to
xrange[i+1]
in the xdirection and yrange[j]
to
yrange[j+1]
in the ydirection. Each bin is inclusive at the lower
end and exclusive at the upper end. Mathematically this means that the
bins are defined by the following inequality,
bin(i,j) corresponds to xrange[i] <= x < xrange[i+1] and yrange[j] <= y < yrange[j+1]
Note that any samples which fall on the upper sides of the histogram are excluded. If you want to include these values for the side bins you will need to add an extra row or column to your histogram.
The gsl_histogram2d
struct and its associated functions are
defined in the header file ‘gsl_histogram2d.h’.
ISBN 0954612078  GNU Scientific Library Reference Manual  Third Edition (v1.12)  See the print edition 