Skip to content

Commit ffe297c

Browse files
DZPMTomAugspurger
authored andcommitted
DOC: update the pandas.DataFrame.hist docstring (#20113)
1 parent 50b2184 commit ffe297c

File tree

1 file changed

+48
-17
lines changed

1 file changed

+48
-17
lines changed

pandas/plotting/_core.py

+48-17
Original file line numberDiff line numberDiff line change
@@ -2173,50 +2173,81 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
21732173
xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False,
21742174
sharey=False, figsize=None, layout=None, bins=10, **kwds):
21752175
"""
2176-
Draw histogram of the DataFrame's series using matplotlib / pylab.
2176+
Make a histogram of the DataFrame's.
2177+
2178+
A `histogram`_ is a representation of the distribution of data.
2179+
This function calls :meth:`matplotlib.pyplot.hist`, on each series in
2180+
the DataFrame, resulting in one histogram per column.
2181+
2182+
.. _histogram: https://en.wikipedia.org/wiki/Histogram
21772183
21782184
Parameters
21792185
----------
21802186
data : DataFrame
2187+
The pandas object holding the data.
21812188
column : string or sequence
2182-
If passed, will be used to limit data to a subset of columns
2189+
If passed, will be used to limit data to a subset of columns.
21832190
by : object, optional
2184-
If passed, then used to form histograms for separate groups
2191+
If passed, then used to form histograms for separate groups.
21852192
grid : boolean, default True
2186-
Whether to show axis grid lines
2193+
Whether to show axis grid lines.
21872194
xlabelsize : int, default None
2188-
If specified changes the x-axis label size
2195+
If specified changes the x-axis label size.
21892196
xrot : float, default None
2190-
rotation of x axis labels
2197+
Rotation of x axis labels. For example, a value of 90 displays the
2198+
x labels rotated 90 degrees clockwise.
21912199
ylabelsize : int, default None
2192-
If specified changes the y-axis label size
2200+
If specified changes the y-axis label size.
21932201
yrot : float, default None
2194-
rotation of y axis labels
2195-
ax : matplotlib axes object, default None
2202+
Rotation of y axis labels. For example, a value of 90 displays the
2203+
y labels rotated 90 degrees clockwise.
2204+
ax : Matplotlib axes object, default None
2205+
The axes to plot the histogram on.
21962206
sharex : boolean, default True if ax is None else False
21972207
In case subplots=True, share x axis and set some x axis labels to
21982208
invisible; defaults to True if ax is None otherwise False if an ax
2199-
is passed in; Be aware, that passing in both an ax and sharex=True
2200-
will alter all x axis labels for all subplots in a figure!
2209+
is passed in.
2210+
Note that passing in both an ax and sharex=True will alter all x axis
2211+
labels for all subplots in a figure.
22012212
sharey : boolean, default False
22022213
In case subplots=True, share y axis and set some y axis labels to
2203-
invisible
2214+
invisible.
22042215
figsize : tuple
2205-
The size of the figure to create in inches by default
2216+
The size in inches of the figure to create. Uses the value in
2217+
`matplotlib.rcParams` by default.
22062218
layout : tuple, optional
2207-
Tuple of (rows, columns) for the layout of the histograms
2219+
Tuple of (rows, columns) for the layout of the histograms.
22082220
bins : integer or sequence, default 10
22092221
Number of histogram bins to be used. If an integer is given, bins + 1
22102222
bin edges are calculated and returned. If bins is a sequence, gives
22112223
bin edges, including left edge of first bin and right edge of last
22122224
bin. In this case, bins is returned unmodified.
2213-
`**kwds` : other plotting keyword arguments
2214-
To be passed to hist function
2225+
**kwds
2226+
All other plotting keyword arguments to be passed to
2227+
:meth:`matplotlib.pyplot.hist`.
2228+
2229+
Returns
2230+
-------
2231+
axes : matplotlib.AxesSubplot or numpy.ndarray of them
22152232
22162233
See Also
22172234
--------
2218-
matplotlib.axes.Axes.hist : Plot a histogram using matplotlib.
2235+
matplotlib.pyplot.hist : Plot a histogram using matplotlib.
2236+
2237+
Examples
2238+
--------
2239+
2240+
.. plot::
2241+
:context: close-figs
2242+
2243+
This example draws a histogram based on the length and width of
2244+
some animals, displayed in three bins
22192245
2246+
>>> df = pd.DataFrame({
2247+
... 'length': [1.5, 0.5, 1.2, 0.9, 3],
2248+
... 'width': [0.7, 0.2, 0.15, 0.2, 1.1]
2249+
... }, index= ['pig', 'rabbit', 'duck', 'chicken', 'horse'])
2250+
>>> hist = df.hist(bins=3)
22202251
"""
22212252
_converter._WARN = False
22222253
if by is not None:

0 commit comments

Comments
 (0)