Skip to content

Commit

Permalink
DOC: Improved the docstring of pandas.plotting._core.FramePlotMethods… (
Browse files Browse the repository at this point in the history
pandas-dev#20157)

* DOC: Improved the docstring of pandas.plotting._core.FramePlotMethods.barh()
- Added examples section
- Added extended summary
- Added argument explanation

* DOC: Improved the docstring of pandas.plotting._core.FramePlotMethods.barh()
- Correcting PR comments

* DOC: Improved the docstring of pandas.plotting._core.FramePlotMethods.barh()
- Adding defaults for variables.

* Update reference
  • Loading branch information
delkk0 authored and TomAugspurger committed Mar 11, 2018
1 parent 0780193 commit f1c0b7c
Showing 1 changed file with 86 additions and 24 deletions.
110 changes: 86 additions & 24 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ def orientation(self):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : matplotlib.axes.Axes or numpy.ndarray of them
See Also
--------
Expand Down Expand Up @@ -1917,7 +1917,7 @@ def _plot(data, x=None, y=None, subplots=False,
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
Notes
-----
Expand Down Expand Up @@ -2581,7 +2581,7 @@ def line(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
Examples
--------
Expand All @@ -2606,7 +2606,7 @@ def bar(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='bar', **kwds)

Expand All @@ -2622,7 +2622,7 @@ def barh(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='barh', **kwds)

Expand All @@ -2638,7 +2638,7 @@ def box(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='box', **kwds)

Expand All @@ -2656,7 +2656,7 @@ def hist(self, bins=10, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='hist', bins=bins, **kwds)

Expand Down Expand Up @@ -2715,7 +2715,7 @@ def area(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='area', **kwds)

Expand All @@ -2731,7 +2731,7 @@ def pie(self, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='pie', **kwds)

Expand Down Expand Up @@ -2783,7 +2783,7 @@ def line(self, x=None, y=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='line', x=x, y=y, **kwds)

Expand All @@ -2801,25 +2801,87 @@ def bar(self, x=None, y=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='bar', x=x, y=y, **kwds)

def barh(self, x=None, y=None, **kwds):
"""
Horizontal bar plot
Make a horizontal bar plot.
A horizontal bar plot is a plot that presents quantitative data with
rectangular bars with lengths proportional to the values that they
represent. A bar plot shows comparisons among discrete categories. One
axis of the plot shows the specific categories being compared, and the
other axis represents a measured value.
Parameters
----------
x, y : label or position, optional
Coordinates for each point.
`**kwds` : optional
Additional keyword arguments are documented in
:meth:`pandas.DataFrame.plot`.
x : label or position, default DataFrame.index
Column to be used for categories.
y : label or position, default All numeric columns in dataframe
Columns to be plotted from the DataFrame.
**kwds
Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`.
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them.
See Also
--------
pandas.DataFrame.plot.bar: Vertical bar plot.
pandas.DataFrame.plot : Make plots of DataFrame using matplotlib.
matplotlib.axes.Axes.bar : Plot a vertical bar plot using matplotlib.
Examples
--------
Basic example
.. plot::
:context: close-figs
>>> df = pd.DataFrame({'lab':['A', 'B', 'C'], 'val':[10, 30, 20]})
>>> ax = df.plot.barh(x='lab', y='val')
Plot a whole DataFrame to a horizontal bar plot
.. plot::
:context: close-figs
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88]
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28]
>>> index = ['snail', 'pig', 'elephant',
... 'rabbit', 'giraffe', 'coyote', 'horse']
>>> df = pd.DataFrame({'speed': speed,
... 'lifespan': lifespan}, index=index)
>>> ax = df.plot.barh()
Plot a column of the DataFrame to a horizontal bar plot
.. plot::
:context: close-figs
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88]
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28]
>>> index = ['snail', 'pig', 'elephant',
... 'rabbit', 'giraffe', 'coyote', 'horse']
>>> df = pd.DataFrame({'speed': speed,
... 'lifespan': lifespan}, index=index)
>>> ax = df.plot.barh(y='speed')
Plot DataFrame versus the desired column
.. plot::
:context: close-figs
>>> speed = [0.1, 17.5, 40, 48, 52, 69, 88]
>>> lifespan = [2, 8, 70, 1.5, 25, 12, 28]
>>> index = ['snail', 'pig', 'elephant',
... 'rabbit', 'giraffe', 'coyote', 'horse']
>>> df = pd.DataFrame({'speed': speed,
... 'lifespan': lifespan}, index=index)
>>> ax = df.plot.barh(x='lifespan')
"""
return self(kind='barh', x=x, y=y, **kwds)

Expand All @@ -2837,7 +2899,7 @@ def box(self, by=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='box', by=by, **kwds)

Expand All @@ -2857,7 +2919,7 @@ def hist(self, by=None, bins=10, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='hist', by=by, bins=bins, **kwds)

Expand Down Expand Up @@ -2921,7 +2983,7 @@ def area(self, x=None, y=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='area', x=x, y=y, **kwds)

Expand All @@ -2939,7 +3001,7 @@ def pie(self, y=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='pie', y=y, **kwds)

Expand All @@ -2961,7 +3023,7 @@ def scatter(self, x, y, s=None, c=None, **kwds):
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
return self(kind='scatter', x=x, y=y, c=c, s=s, **kwds)

Expand All @@ -2987,7 +3049,7 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None,
Returns
-------
axes : matplotlib.AxesSubplot or np.array of them
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
"""
if reduce_C_function is not None:
kwds['reduce_C_function'] = reduce_C_function
Expand Down

0 comments on commit f1c0b7c

Please sign in to comment.