Skip to content

Commit 9c4dbe8

Browse files
committed
minor fixes from comments and new example using np.random.randn()
1 parent dc9aabf commit 9c4dbe8

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed

pandas/plotting/_core.py

+17-20
Original file line numberDiff line numberDiff line change
@@ -2876,25 +2876,23 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None,
28762876
"""
28772877
Make hexagonal binning plots.
28782878
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`
2879+
Make an hexagonal binning plot of `x` versus `y`. If `C` is `None`
28812880
(the default), this is an histogram of the number of occurrences
28822881
of the observations at (x[i],y[i]).
28832882
28842883
If `C` is specified, specifies values at given coordinates
28852884
(x[i],y[i]). These values are accumulated for each hexagonal
28862885
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`.)
2886+
having as default the numpy's mean function (np.mean).
2887+
(If `C` is specified, it must also be a 1-D sequence
2888+
of the same length as `x` and `y`.)
28912889
28922890
Parameters
28932891
----------
2894-
x : label or position, optional
2895-
Coordinates for x point.
2896-
y : label or position, optional
2897-
Coordinates for y point.
2892+
x : label or position
2893+
Coordinates for x points.
2894+
y : label or position
2895+
Coordinates for y points.
28982896
C : label or position, optional
28992897
The value at each `(x, y)` point.
29002898
reduce_C_function : callable, optional, default `mean`
@@ -2905,31 +2903,30 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None,
29052903
The corresponding number of hexagons in the y-direction is
29062904
chosen in a way that the hexagons are approximately regular.
29072905
Alternatively,
2908-
gridsize can be a tuple with two elements specifying the number of
2909-
hexagons in the x-direction and the y-direction.
2906+
gridsize can be a tuple with two elements specifying the number
2907+
of hexagons in the x-direction and the y-direction.
29102908
kwds : optional
29112909
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`.
29122910
29132911
Returns
29142912
-------
2915-
axes : matplotlib.AxesSubplot or np.array of them.
2913+
axes : matplotlib.AxesSubplot.
29162914
29172915
See Also
29182916
--------
2919-
matplotlib.pyplot.hexbin : hexagonal binning plot using matplotlib.
2917+
matplotlib.pyplot.hexbin : hexagonal binning plot using matplotlib,
2918+
the matplotlib function that is used under the hood.
29202919
29212920
Examples
29222921
--------
29232922
29242923
.. plot::
29252924
:context: close-figs
29262925
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)',
2931-
... y='sepal width (cm)',
2932-
... gridsize=10, cmap='viridis')
2926+
>>> n = 100000
2927+
>>> df = pd.DataFrame({'x':np.random.randn(n),
2928+
... 'y':np.random.randn(n)})
2929+
>>> hexbin = df.plot.hexbin(x='x', y='y', cmap='viridis')
29332930
"""
29342931
if reduce_C_function is not None:
29352932
kwds['reduce_C_function'] = reduce_C_function

0 commit comments

Comments
 (0)