Skip to content

Commit 8995dc3

Browse files
committed
DOC: Improve dosctring for pandas.DataFrame.hist
1 parent 4131149 commit 8995dc3

File tree

1 file changed

+45
-16
lines changed

1 file changed

+45
-16
lines changed

pandas/plotting/_core.py

+45-16
Original file line numberDiff line numberDiff line change
@@ -2128,50 +2128,79 @@ def hist_frame(data, column=None, by=None, grid=True, xlabelsize=None,
21282128
xrot=None, ylabelsize=None, yrot=None, ax=None, sharex=False,
21292129
sharey=False, figsize=None, layout=None, bins=10, **kwds):
21302130
"""
2131-
Draw histogram of the DataFrame's series using matplotlib / pylab.
2131+
Draw histogram of the DataFrame's columns using matplotlib.
2132+
2133+
A histogram is a representation of the distribution of data.
2134+
This function wraps the matplotlib histogram function for each series in
2135+
the DataFrame. It returns an array with a plot for each histogram.
21322136
21332137
Parameters
21342138
----------
21352139
data : DataFrame
2140+
The pandas object holding the data.
21362141
column : string or sequence
2137-
If passed, will be used to limit data to a subset of columns
2142+
If passed, will be used to limit data to a subset of columns.
21382143
by : object, optional
2139-
If passed, then used to form histograms for separate groups
2144+
If passed, then used to form histograms for separate groups.
21402145
grid : boolean, default True
2141-
Whether to show axis grid lines
2146+
Whether to show axis grid lines.
21422147
xlabelsize : int, default None
2143-
If specified changes the x-axis label size
2148+
If specified changes the x-axis label size.
21442149
xrot : float, default None
2145-
rotation of x axis labels
2150+
Rotation of x axis labels. For example, a value of 90 displays the
2151+
x labels rotated 90 degrees clockwise.
21462152
ylabelsize : int, default None
2147-
If specified changes the y-axis label size
2153+
If specified changes the y-axis label size.
21482154
yrot : float, default None
2149-
rotation of y axis labels
2150-
ax : matplotlib axes object, default None
2155+
Rotation of y axis labels. For example, a value of 90 displays the
2156+
y labels rotated 90 degrees clockwise.
2157+
ax : Matplotlib axes object, default None
2158+
The axes to plot the histogram on.
21512159
sharex : boolean, default True if ax is None else False
21522160
In case subplots=True, share x axis and set some x axis labels to
21532161
invisible; defaults to True if ax is None otherwise False if an ax
2154-
is passed in; Be aware, that passing in both an ax and sharex=True
2155-
will alter all x axis labels for all subplots in a figure!
2162+
is passed in.
2163+
Note that passing in both an ax and sharex=True will alter all x axis
2164+
labels for all subplots in a figure.
21562165
sharey : boolean, default False
21572166
In case subplots=True, share y axis and set some y axis labels to
2158-
invisible
2167+
invisible.
21592168
figsize : tuple
2160-
The size of the figure to create in inches by default
2169+
The size in inches of the figure to create. Uses the value in
2170+
`matplotlib.rcParams` by default.
21612171
layout : tuple, optional
2162-
Tuple of (rows, columns) for the layout of the histograms
2172+
Tuple of (rows, columns) for the layout of the histograms.
21632173
bins : integer or sequence, default 10
21642174
Number of histogram bins to be used. If an integer is given, bins + 1
21652175
bin edges are calculated and returned. If bins is a sequence, gives
21662176
bin edges, including left edge of first bin and right edge of last
21672177
bin. In this case, bins is returned unmodified.
2168-
`**kwds` : other plotting keyword arguments
2169-
To be passed to hist function
2178+
kwds : optional
2179+
All other plotting keyword arguments to be passed to
2180+
matplotlib's boxplot function.
2181+
2182+
Returns
2183+
-------
2184+
axes : matplotlib.AxesSubplot or numpy.ndarray of them
21702185
21712186
See Also
21722187
--------
21732188
matplotlib.axes.Axes.hist : Plot a histogram using matplotlib.
21742189
2190+
Examples
2191+
--------
2192+
2193+
.. plot::
2194+
:context: close-figs
2195+
2196+
This example draws a histogram based on the length and width of
2197+
some animals, displayed in three bins
2198+
2199+
>>> df = pd.DataFrame({
2200+
... 'length': [1.5, 0.5, 1.2, 0.9, 3],
2201+
... 'width': [0.7, 0.2, 0.15, 0.2, 1.1]
2202+
... }, index= ['pig', 'rabbit', 'duck', 'chicken', 'horse'])
2203+
>>> hist = df.hist(bins=3)
21752204
"""
21762205
_converter._WARN = False
21772206
if by is not None:

0 commit comments

Comments
 (0)