Pandas DataFrame: plot.hexbin() function
DataFrame.plot.hexbin() function
The plot.hexbin() function is used to generate a hexagonal binning plot.
Generate a hexagonal binning plot of x versus y. If C is None (the default), this is a histogram of the number of occurrences of the observations at (x[i], y[i]).
If C is specified, specifies values at given coordinates (x[i], y[i]). These values are accumulated for each hexagonal bin and then reduced according to reduce_C_function, having as default the NumPy’s mean function (numpy.mean()). (If C is specified, it must also be a 1-D sequence of the same length as x and y, or a column label.)
Syntax:
DataFrame.plot.hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None, **kwargs)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
x | The column label or position for x points. | int or str | Required |
y | The column label or position for y points. | int or str | Required |
C | The column label or position for the value of (x, y) point. | int or str | Optional |
reduce_C_function | Function of one argument that reduces all the values in a bin to a single number (e.g. np.mean, np.max, np.sum, np.std). | callable Default Value: np.mean |
|
gridsize | The number of hexagons in the x-direction. The corresponding number of hexagons in the y-direction is chosen in a way that the hexagons are approximately regular. Alternatively, gridsize can be a tuple with two elements specifying the number of hexagons in the x-direction and the y-direction. | int or tuple of (int, int) Default Value: 100 |
|
**kwds | Additional keyword arguments are documented in DataFrame.plot(). |
Returns: matplotlib.AxesSubplot
The matplotlib Axes on which the hexbin is plotted.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame-plot-density() function
Next: DataFrame.plot.hist() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/pandas/dataframe/dataframe-plot-hexbin.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics