Two-dimensional histogram calculation.