hexbin(x, y, C=None, gridsize=100, bins=None, xscale='linear', yscale='linear', extent=None, cmap=None, norm=None, vmin=None, vmax=None, alpha=None, linewidths=None, edgecolors='face', reduce_C_function=<function mean at 0x0000000>, mincnt=None, marginals=False, *, data=None, **kwargs)
If C is None, the value of the hexagon is determined by the number of points in the hexagon. Otherwise, C specifies values at the coordinate (x[i], y[i]). For each hexagon, these values are reduced using reduce_C_function.
The Colormap instance or registered colormap name used to map the bin values to colors.
The Normalize instance scales the bin values to the canonical colormap range [0, 1] for mapping to colors. By default, the data range is mapped to the colorbar range using linear scaling.
The colorbar range. If None, suitable min/max values are automatically chosen by the .Normalize
instance (defaults to the respective min/max values of the bins in case of the default linear scaling). It is an error to use vmin/vmax when norm is given.
The alpha blending value, between 0 (transparent) and 1 (opaque).
If None, defaults to 1.0.
The color of the hexagon edges. Possible values are:
'face': Draw the edges in the same color as the fill color.
'none': No edges are drawn. This can sometimes lead to unsightly unpainted pixels between the hexagons.
None: Draw outlines in the default color.
An explicit color.
The function to aggregate C within the bins. It is ignored if C is not given. This must have the signature:
def reduce_C_function(C: array) -> float
Commonly used functions are:
numpy.mean
: average of the points
numpy.sum
: integral of the point values
numpy.amax
: value taken from the largest point
If given, the following parameters also accept a string s
, which is interpreted as data[s]
(unless this raises an exception):
x, y, C
All other keyword arguments are passed on to .PolyCollection
:
Properties: agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array alpha: array-like or scalar or None animated: bool antialiased or aa or antialiaseds: bool or list of bools array: array-like or None capstyle: .CapStyle
or {'butt', 'projecting', 'round'} clim: (vmin: float, vmax: float) clip_box: .Bbox
clip_on: bool clip_path: Patch or (Path, Transform) or None cmap: .Colormap
or str or None color: color or list of rgba tuples edgecolor or ec or edgecolors: color or list of colors or 'face' facecolor or facecolors or fc: color or list of colors figure: .Figure
gid: str hatch: {'/', '\\', '|', '-', '+', 'x', 'o', 'O', '.', '*'} in_layout: bool joinstyle: .JoinStyle
or {'miter', 'round', 'bevel'} label: object linestyle or dashes or linestyles or ls: str or tuple or list thereof linewidth or linewidths or lw: float or list of floats norm: .Normalize
or None offset_transform: .Transform
offsets: (N, 2) or (2,) array-like path_effects: .AbstractPathEffect
paths: list of array-like picker: None or bool or float or callable pickradius: float rasterized: bool sizes: ndarray or None sketch_params: (scale: float, length: float, randomness: float) snap: bool or None transform: .Transform
url: str urls: list of str or None verts: list of array-like verts_and_codes: unknown visible: bool zorder: float
The data positions. x and y must be of the same length.
If given, these values are accumulated in the bins. Otherwise, every point has a value of 1. Must be of the same length as x and y.
If a single int, the number of hexagons in the x-direction. The number of hexagons in the y-direction is chosen such that the hexagons are approximately regular.
Alternatively, if a tuple (nx, ny), the number of hexagons in the x-direction and the y-direction.
Discretization of the hexagon values.
If None, no binning is applied; the color of each hexagon directly corresponds to its count value.
If 'log', use a logarithmic scale for the colormap. Internally, $log_{10}(i+1)$
is used to determine the hexagon color. This is equivalent to norm=LogNorm()
.
If an integer, divide the counts in the specified number of bins, and color the hexagons accordingly.
If a sequence of values, the values of the lower bound of the bins to be used.
Use a linear or log10 scale on the horizontal axis.
Use a linear or log10 scale on the vertical axis.
If not None, only display cells with more than mincnt number of points in the cell.
If marginals is True, plot the marginal density as colormapped rectangles along the bottom of the x-axis and left of the y-axis.
The limits of the bins (xmin, xmax, ymin, ymax). The default assigns the limits based on gridsize, x, y, xscale and yscale.
If xscale or yscale is set to 'log', the limits are expected to be the exponent for a power of 10. E.g. for x-limits of 1 and 50 in 'linear' scale and y-limits of 10 and 1000 in 'log' scale, enter (1, 50, 1, 3).
A .PolyCollection
defining the hexagonal bins.
:None:None:`.PolyCollection.get_offsets`
contains a Mx2 array containing the x, y positions of the M hexagon centers.
:None:None:`.PolyCollection.get_array`
contains the values of the M hexagons.
If marginals is True, horizontal bar and vertical bar (both PolyCollections) will be attached to the return collection as attributes hbar and vbar.
Make a 2D hexagonal binning plot of points x, y.
hist2d
2D histogram rectangular bins
The following pages refer to to this document either explicitly or contain code examples using this.
matplotlib.pyplot.hist2d
pandas.plotting._core.PlotAccessor.hexbin
matplotlib.pyplot.hist
matplotlib.pyplot.plotting
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