Skip to content

Commit 98cebfd

Browse files
liopicAndrew Bui
authored and
Andrew Bui
committed
DOC: update the pandas.DataFrame.plot.hist docstring (pandas-dev#20155)
1 parent d434bf7 commit 98cebfd

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

pandas/plotting/_core.py

+32-6
Original file line numberDiff line numberDiff line change
@@ -3049,21 +3049,47 @@ def box(self, by=None, **kwds):
30493049

30503050
def hist(self, by=None, bins=10, **kwds):
30513051
"""
3052-
Histogram
3052+
Draw one histogram of the DataFrame's columns.
3053+
3054+
A histogram is a representation of the distribution of data.
3055+
This function groups the values of all given Series in the DataFrame
3056+
into bins, and draws all bins in only one :ref:`matplotlib.axes.Axes`.
3057+
This is useful when the DataFrame's Series are in a similar scale.
30533058
30543059
Parameters
30553060
----------
3056-
by : string or sequence
3061+
by : str or sequence, optional
30573062
Column in the DataFrame to group by.
3058-
bins: integer, default 10
3059-
Number of histogram bins to be used
3060-
`**kwds` : optional
3063+
bins : int, default 10
3064+
Number of histogram bins to be used.
3065+
**kwds
30613066
Additional keyword arguments are documented in
30623067
:meth:`pandas.DataFrame.plot`.
30633068
30643069
Returns
30653070
-------
3066-
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
3071+
axes : matplotlib.AxesSubplot histogram.
3072+
3073+
See Also
3074+
--------
3075+
DataFrame.hist : Draw histograms per DataFrame's Series.
3076+
Series.hist : Draw a histogram with Series' data.
3077+
3078+
Examples
3079+
--------
3080+
When we draw a dice 6000 times, we expect to get each value around 1000
3081+
times. But when we draw two dices and sum the result, the distribution
3082+
is going to be quite different. A histogram illustrates those
3083+
distributions.
3084+
3085+
.. plot::
3086+
:context: close-figs
3087+
3088+
>>> df = pd.DataFrame(
3089+
... np.random.randint(1, 7, 6000),
3090+
... columns = ['one'])
3091+
>>> df['two'] = df['one'] + np.random.randint(1, 7, 6000)
3092+
>>> ax = df.plot.hist(bins=12, alpha=0.5)
30673093
"""
30683094
return self(kind='hist', by=by, bins=bins, **kwds)
30693095

0 commit comments

Comments
 (0)