Compute the bidimensional histogram of two data samples.
Parameters: | x : array_like, shape(N,)
y : array_like, shape(M,)
bins : int or [int, int] or array-like or [array, array], optional
range : array_like, shape(2,2), optional
normed : boolean, optional
weights : array-like, shape(N,), optional
|
---|---|
Returns: | H : ndarray, shape(nx, ny)
xedges : ndarray, shape(nx,)
yedges : ndarray, shape(ny,)
|
See also
Notes
When normed is True, then the returned histogram is the sample density, defined such that:
where is the histogram array and the area of bin .
Please note that the histogram does not follow the cartesian convention where x values are on the abcissa and y values on the ordinate axis. Rather, x is histogrammed along the first dimension of the array (vertical), and y along the second dimension of the array (horizontal). This ensures compatibility with histogrammdd.
Examples
>>> x,y = np.random.randn(2,100)
>>> H, xedges, yedges = np.histogram2d(x, y, bins = (5, 8))
>>> H.shape, xedges.shape, yedges.shape
((5,8), (6,), (9,))