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)
| 694 | |
| 695 | @array_function_dispatch(_histogram2d_dispatcher) |
| 696 | def histogram2d(x, y, bins=10, range=None, density=None, weights=None): |
| 697 | """ |
| 698 | Compute the bi-dimensional histogram of two data samples. |
| 699 | |
| 700 | Parameters |
| 701 | ---------- |
| 702 | x : array_like, shape (N,) |
| 703 | An array containing the x coordinates of the points to be |
| 704 | histogrammed. |
| 705 | y : array_like, shape (N,) |
| 706 | An array containing the y coordinates of the points to be |
| 707 | histogrammed. |
| 708 | bins : int or array_like or [int, int] or [array, array], optional |
| 709 | The bin specification: |
| 710 | |
| 711 | * If int, the number of bins for the two dimensions (nx=ny=bins). |
| 712 | * If array_like, the bin edges for the two dimensions |
| 713 | (x_edges=y_edges=bins). |
| 714 | * If [int, int], the number of bins in each dimension |
| 715 | (nx, ny = bins). |
| 716 | * If [array, array], the bin edges in each dimension |
| 717 | (x_edges, y_edges = bins). |
| 718 | * A combination [int, array] or [array, int], where int |
| 719 | is the number of bins and array is the bin edges. |
| 720 | |
| 721 | range : array_like, shape(2,2), optional |
| 722 | The leftmost and rightmost edges of the bins along each dimension |
| 723 | (if not specified explicitly in the `bins` parameters): |
| 724 | ``[[xmin, xmax], [ymin, ymax]]``. All values outside of this range |
| 725 | will be considered outliers and not tallied in the histogram. |
| 726 | density : bool, optional |
| 727 | If False, the default, returns the number of samples in each bin. |
| 728 | If True, returns the probability *density* function at the bin, |
| 729 | ``bin_count / sample_count / bin_area``. |
| 730 | weights : array_like, shape(N,), optional |
| 731 | An array of values ``w_i`` weighing each sample ``(x_i, y_i)``. |
| 732 | Weights are normalized to 1 if `density` is True. If `density` is |
| 733 | False, the values of the returned histogram are equal to the sum of |
| 734 | the weights belonging to the samples falling into each bin. |
| 735 | |
| 736 | Returns |
| 737 | ------- |
| 738 | H : ndarray, shape(nx, ny) |
| 739 | The bi-dimensional histogram of samples `x` and `y`. Values in `x` |
| 740 | are histogrammed along the first dimension and values in `y` are |
| 741 | histogrammed along the second dimension. |
| 742 | xedges : ndarray, shape(nx+1,) |
| 743 | The bin edges along the first dimension. |
| 744 | yedges : ndarray, shape(ny+1,) |
| 745 | The bin edges along the second dimension. |
| 746 | |
| 747 | See Also |
| 748 | -------- |
| 749 | histogram : 1D histogram |
| 750 | histogramdd : Multidimensional histogram |
| 751 | |
| 752 | Notes |
| 753 | ----- |
searching dependent graphs…