@@ -2874,25 +2874,61 @@ def scatter(self, x, y, s=None, c=None, **kwds):
2874
2874
def hexbin (self , x , y , C = None , reduce_C_function = None , gridsize = None ,
2875
2875
** kwds ):
2876
2876
"""
2877
- Hexbin plot
2877
+ Make hexagonal binning plots.
2878
+
2879
+ Make an hexagonal binning plot of `x` versus `y`, where `x`,
2880
+ `y` are 1-D sequences of the same length, `N`. If `C` is `None`
2881
+ (the default), this is an histogram of the number of occurrences
2882
+ of the observations at (x[i],y[i]).
2883
+
2884
+ If `C` is specified, specifies values at given coordinates
2885
+ (x[i],y[i]). These values are accumulated for each hexagonal
2886
+ bin and then reduced according to `reduce_C_function`,
2887
+ having as default
2888
+ the numpy's mean function (np.mean). (If *C* is
2889
+ specified, it must also be a 1-D sequence of the same length
2890
+ as `x` and `y`.)
2878
2891
2879
2892
Parameters
2880
2893
----------
2881
- x, y : label or position, optional
2882
- Coordinates for each point.
2894
+ x : label or position, optional
2895
+ Coordinates for x point.
2896
+ y : label or position, optional
2897
+ Coordinates for y point.
2883
2898
C : label or position, optional
2884
2899
The value at each `(x, y)` point.
2885
- reduce_C_function : callable, optional
2900
+ reduce_C_function : callable, optional, default `mean`
2886
2901
Function of one argument that reduces all the values in a bin to
2887
2902
a single number (e.g. `mean`, `max`, `sum`, `std`).
2888
- gridsize : int, optional
2889
- Number of bins.
2890
- `**kwds` : optional
2903
+ gridsize : int, optional, default 100
2904
+ The number of hexagons in the x-direction.
2905
+ The corresponding number of hexagons in the y-direction is
2906
+ chosen in a way that the hexagons are approximately regular.
2907
+ Alternatively,
2908
+ gridsize can be a tuple with two elements specifying the number of
2909
+ hexagons in the x-direction and the y-direction.
2910
+ kwds : optional
2891
2911
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`.
2892
2912
2893
2913
Returns
2894
2914
-------
2895
- axes : matplotlib.AxesSubplot or np.array of them
2915
+ axes : matplotlib.AxesSubplot or np.array of them.
2916
+
2917
+ See Also
2918
+ --------
2919
+ matplotlib.pyplot.hexbin : hexagonal binning plot using matplotlib.
2920
+
2921
+ Examples
2922
+ --------
2923
+
2924
+ .. plot::
2925
+ :context: close-figs
2926
+
2927
+ >>> from sklearn.datasets import load_iris
2928
+ >>> iris = load_iris()
2929
+ >>> df = pd.DataFrame(iris.data, columns=iris.feature_names)
2930
+ >>> hexbin = df.plot.hexbin(x='sepal length (cm)', y='sepal width (cm)',
2931
+ ... gridsize=10, cmap='viridis')
2896
2932
"""
2897
2933
if reduce_C_function is not None :
2898
2934
kwds ['reduce_C_function' ] = reduce_C_function
0 commit comments