MCPcopy Create free account
hub / github.com/numpy/numpy / histogram2d

Function histogram2d

numpy/lib/twodim_base.py:644–809  ·  view source on GitHub ↗

Compute the bi-dimensional histogram of two data samples. Parameters ---------- x : array_like, shape (N,) An array containing the x coordinates of the points to be histogrammed. y : array_like, shape (N,) An array containing the y coordinates of the poi

(x, y, bins=10, range=None, density=None, weights=None)

Source from the content-addressed store, hash-verified

642
643@array_function_dispatch(_histogram2d_dispatcher)
644def histogram2d(x, y, bins=10, range=None, density=None, weights=None):
645 """
646 Compute the bi-dimensional histogram of two data samples.
647
648 Parameters
649 ----------
650 x : array_like, shape (N,)
651 An array containing the x coordinates of the points to be
652 histogrammed.
653 y : array_like, shape (N,)
654 An array containing the y coordinates of the points to be
655 histogrammed.
656 bins : int or array_like or [int, int] or [array, array], optional
657 The bin specification:
658
659 * If int, the number of bins for the two dimensions (nx=ny=bins).
660 * If array_like, the bin edges for the two dimensions
661 (x_edges=y_edges=bins).
662 * If [int, int], the number of bins in each dimension
663 (nx, ny = bins).
664 * If [array, array], the bin edges in each dimension
665 (x_edges, y_edges = bins).
666 * A combination [int, array] or [array, int], where int
667 is the number of bins and array is the bin edges.
668
669 range : array_like, shape(2,2), optional
670 The leftmost and rightmost edges of the bins along each dimension
671 (if not specified explicitly in the `bins` parameters):
672 ``[[xmin, xmax], [ymin, ymax]]``. All values outside of this range
673 will be considered outliers and not tallied in the histogram.
674 density : bool, optional
675 If False, the default, returns the number of samples in each bin.
676 If True, returns the probability *density* function at the bin,
677 ``bin_count / sample_count / bin_area``.
678 weights : array_like, shape(N,), optional
679 An array of values ``w_i`` weighing each sample ``(x_i, y_i)``.
680 Weights are normalized to 1 if `density` is True. If `density` is
681 False, the values of the returned histogram are equal to the sum of
682 the weights belonging to the samples falling into each bin.
683
684 Returns
685 -------
686 H : ndarray, shape(nx, ny)
687 The bi-dimensional histogram of samples `x` and `y`. Values in `x`
688 are histogrammed along the first dimension and values in `y` are
689 histogrammed along the second dimension.
690 xedges : ndarray, shape(nx+1,)
691 The bin edges along the first dimension.
692 yedges : ndarray, shape(ny+1,)
693 The bin edges along the second dimension.
694
695 See Also
696 --------
697 histogram : 1D histogram
698 histogramdd : Multidimensional histogram
699
700 Notes
701 -----

Callers 8

test_simpleMethod · 0.90
test_asymMethod · 0.90
test_densityMethod · 0.90
test_all_outliersMethod · 0.90
test_emptyMethod · 0.90
test_dispatchMethod · 0.90
test_bad_lengthMethod · 0.90

Calls 2

histogramddFunction · 0.90
asarrayFunction · 0.50

Tested by 8

test_simpleMethod · 0.72
test_asymMethod · 0.72
test_densityMethod · 0.72
test_all_outliersMethod · 0.72
test_emptyMethod · 0.72
test_dispatchMethod · 0.72
test_bad_lengthMethod · 0.72