matplotlib 3.5.1

NotesOther ParametersParametersReturnsBackRef
hist2d(x, y, bins=10, range=None, density=False, weights=None, cmin=None, cmax=None, *, data=None, **kwargs)

Notes

Other Parameters

cmap : Colormap or str, optional

A .colors.Colormap instance. If not set, use rc settings.

norm : Normalize, optional

A .colors.Normalize instance is used to scale luminance data to [0, 1] . If not set, defaults to :None:None:`.colors.Normalize()`.

vmin/vmax : None or scalar, optional

Arguments passed to the ~.colors.Normalize instance.

alpha : ``0 <= scalar <= 1`` or ``None``, optional

The alpha blending value.

data : indexable object, optional

If given, the following parameters also accept a string s , which is interpreted as data[s] (unless this raises an exception):

x, y, weights

**kwargs :

Additional parameters are passed along to the ~.Axes.pcolormesh method and ~matplotlib.collections.QuadMesh constructor.

Parameters

x, y : array-like, shape (n, )

Input values

bins : None or int or [int, int] or array-like or [array, array]

The bin specification:

  • If int, the number of bins for the two dimensions (nx=ny=bins).

  • If [int, int] , the number of bins in each dimension (nx, ny = bins).

  • If array-like, the bin edges for the two dimensions (x_edges=y_edges=bins).

  • If [array, array] , the bin edges in each dimension (x_edges, y_edges = bins).

The default value is 10.

range : array-like shape(2, 2), optional

The leftmost and rightmost edges of the bins along each dimension (if not specified explicitly in the bins parameters): [[xmin, xmax], [ymin, ymax]] . All values outside of this range will be considered outliers and not tallied in the histogram.

density : bool, default: False

Normalize histogram. See the documentation for the density parameter of ~.Axes.hist for more details.

weights : array-like, shape (n, ), optional

An array of values w_i weighing each sample (x_i, y_i).

cmin, cmax : float, default: None

All bins that has count less than cmin or more than cmax will not be displayed (set to NaN before passing to imshow) and these count values in the return value count histogram will also be set to nan upon return.

Returns

h : 2D array

The bi-dimensional histogram of samples x and y. Values in x are histogrammed along the first dimension and values in y are histogrammed along the second dimension.

xedges : 1D array

The bin edges along the x axis.

yedges : 1D array

The bin edges along the y axis.

image : `~.matplotlib.collections.QuadMesh`

Make a 2D histogram plot.

See Also

hexbin

2D histogram with hexagonal bins

hist

1D histogram plotting

Examples

See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

matplotlib.pyplot.hist matplotlib.pyplot.plotting matplotlib.pyplot.hexbin

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /matplotlib/pyplot.py#2610
type: <class 'function'>
Commit: