Skip to content

Commit ff32786

Browse files
committed
DOC: change plot docstring to inline from @doc for SeriesGroupBy
1 parent 352e582 commit ff32786

File tree

1 file changed

+216
-1
lines changed

1 file changed

+216
-1
lines changed

pandas/core/groupby/generic.py

Lines changed: 216 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1629,8 +1629,223 @@ def alt(obj):
16291629
)
16301630

16311631
@property
1632-
@doc(Series.plot.__doc__)
16331632
def plot(self) -> GroupByPlot:
1633+
"""
1634+
Make plots of Series or DataFrame.
1635+
1636+
Uses the backend specified by the
1637+
option ``plotting.backend``. By default, matplotlib is used.
1638+
1639+
Parameters
1640+
----------
1641+
data : Series or DataFrame
1642+
The object for which the method is called.
1643+
1644+
Attributes
1645+
----------
1646+
x : label or position, default None
1647+
Only used if data is a DataFrame.
1648+
y : label, position or list of label, positions, default None
1649+
Allows plotting of one column versus another. Only used if data is a
1650+
DataFrame.
1651+
kind : str
1652+
The kind of plot to produce:
1653+
1654+
- 'line' : line plot (default)
1655+
- 'bar' : vertical bar plot
1656+
- 'barh' : horizontal bar plot
1657+
- 'hist' : histogram
1658+
- 'box' : boxplot
1659+
- 'kde' : Kernel Density Estimation plot
1660+
- 'density' : same as 'kde'
1661+
- 'area' : area plot
1662+
- 'pie' : pie plot
1663+
- 'scatter' : scatter plot (DataFrame only)
1664+
- 'hexbin' : hexbin plot (DataFrame only)
1665+
ax : matplotlib axes object, default None
1666+
An axes of the current figure.
1667+
subplots : bool or sequence of iterables, default False
1668+
Whether to group columns into subplots:
1669+
1670+
- ``False`` : No subplots will be used
1671+
- ``True`` : Make separate subplots for each column.
1672+
- sequence of iterables of column labels: Create a subplot for each
1673+
group of columns. For example `[('a', 'c'), ('b', 'd')]` will
1674+
create 2 subplots: one with columns 'a' and 'c', and one
1675+
with columns 'b' and 'd'. Remaining columns that aren't specified
1676+
will be plotted in additional subplots (one per column).
1677+
1678+
.. versionadded:: 1.5.0
1679+
1680+
sharex : bool, default True if ax is None else False
1681+
In case ``subplots=True``, share x axis and set some x axis labels
1682+
to invisible; defaults to True if ax is None otherwise False if
1683+
an ax is passed in; Be aware, that passing in both an ax and
1684+
``sharex=True`` will alter all x axis labels for all axis in a figure.
1685+
sharey : bool, default False
1686+
In case ``subplots=True``, share y axis and set some y axis labels to invisible.
1687+
layout : tuple, optional
1688+
(rows, columns) for the layout of subplots.
1689+
figsize : a tuple (width, height) in inches
1690+
Size of a figure object.
1691+
use_index : bool, default True
1692+
Use index as ticks for x axis.
1693+
title : str or list
1694+
Title to use for the plot. If a string is passed, print the string
1695+
at the top of the figure. If a list is passed and `subplots` is
1696+
True, print each item in the list above the corresponding subplot.
1697+
grid : bool, default None (matlab style default)
1698+
Axis grid lines.
1699+
legend : bool or {'reverse'}
1700+
Place legend on axis subplots.
1701+
style : list or dict
1702+
The matplotlib line style per column.
1703+
logx : bool or 'sym', default False
1704+
Use log scaling or symlog scaling on x axis.
1705+
1706+
logy : bool or 'sym' default False
1707+
Use log scaling or symlog scaling on y axis.
1708+
1709+
loglog : bool or 'sym', default False
1710+
Use log scaling or symlog scaling on both x and y axes.
1711+
1712+
xticks : sequence
1713+
Values to use for the xticks.
1714+
yticks : sequence
1715+
Values to use for the yticks.
1716+
xlim : 2-tuple/list
1717+
Set the x limits of the current axes.
1718+
ylim : 2-tuple/list
1719+
Set the y limits of the current axes.
1720+
xlabel : label, optional
1721+
Name to use for the xlabel on x-axis. Default uses index name as xlabel, or the
1722+
x-column name for planar plots.
1723+
1724+
.. versionchanged:: 2.0.0
1725+
1726+
Now applicable to histograms.
1727+
1728+
ylabel : label, optional
1729+
Name to use for the ylabel on y-axis. Default will show no ylabel, or the
1730+
y-column name for planar plots.
1731+
1732+
.. versionchanged:: 2.0.0
1733+
1734+
Now applicable to histograms.
1735+
1736+
rot : float, default None
1737+
Rotation for ticks (xticks for vertical, yticks for horizontal
1738+
plots).
1739+
fontsize : float, default None
1740+
Font size for xticks and yticks.
1741+
colormap : str or matplotlib colormap object, default None
1742+
Colormap to select colors from. If string, load colormap with that
1743+
name from matplotlib.
1744+
colorbar : bool, optional
1745+
If True, plot colorbar (only relevant for 'scatter' and 'hexbin'
1746+
plots).
1747+
position : float
1748+
Specify relative alignments for bar plot layout.
1749+
From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5
1750+
(center).
1751+
table : bool, Series or DataFrame, default False
1752+
If True, draw a table using the data in the DataFrame and the data
1753+
will be transposed to meet matplotlib's default layout.
1754+
If a Series or DataFrame is passed, use passed data to draw a
1755+
table.
1756+
yerr : DataFrame, Series, array-like, dict and str
1757+
See :ref:`Plotting with Error Bars <visualization.errorbars>` for
1758+
detail.
1759+
xerr : DataFrame, Series, array-like, dict and str
1760+
Equivalent to yerr.
1761+
stacked : bool, default False in line and bar plots, and True in area plot
1762+
If True, create stacked plot.
1763+
secondary_y : bool or sequence, default False
1764+
Whether to plot on the secondary y-axis if a list/tuple, which
1765+
columns to plot on secondary y-axis.
1766+
mark_right : bool, default True
1767+
When using a secondary_y axis, automatically mark the column
1768+
labels with "(right)" in the legend.
1769+
include_bool : bool, default is False
1770+
If True, boolean values can be plotted.
1771+
backend : str, default None
1772+
Backend to use instead of the backend specified in the option
1773+
``plotting.backend``. For instance, 'matplotlib'. Alternatively, to
1774+
specify the ``plotting.backend`` for the whole session, set
1775+
``pd.options.plotting.backend``.
1776+
**kwargs
1777+
Options to pass to matplotlib plotting method.
1778+
1779+
Returns
1780+
-------
1781+
:class:`matplotlib.axes.Axes` or numpy.ndarray of them
1782+
If the backend is not the default matplotlib one, the return value
1783+
will be the object returned by the backend.
1784+
1785+
See Also
1786+
--------
1787+
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.
1788+
DataFrame.hist : Make a histogram.
1789+
DataFrame.boxplot : Make a box plot.
1790+
DataFrame.plot.scatter : Make a scatter plot with varying marker
1791+
point size and color.
1792+
DataFrame.plot.hexbin : Make a hexagonal binning plot of
1793+
two variables.
1794+
DataFrame.plot.kde : Make Kernel Density Estimate plot using
1795+
Gaussian kernels.
1796+
DataFrame.plot.area : Make a stacked area plot.
1797+
DataFrame.plot.bar : Make a bar plot.
1798+
DataFrame.plot.barh : Make a horizontal bar plot.
1799+
1800+
Notes
1801+
-----
1802+
- See matplotlib documentation online for more on this subject
1803+
- If `kind` = 'bar' or 'barh', you can specify relative alignments
1804+
for bar plot layout by `position` keyword.
1805+
From 0 (left/bottom-end) to 1 (right/top-end). Default is 0.5
1806+
(center)
1807+
1808+
Examples
1809+
--------
1810+
For Series:
1811+
1812+
.. plot::
1813+
:context: close-figs
1814+
1815+
>>> ser = pd.Series([1, 2, 3, 3])
1816+
>>> plot = ser.plot(kind="hist", title="My plot")
1817+
1818+
For DataFrame:
1819+
1820+
.. plot::
1821+
:context: close-figs
1822+
1823+
>>> df = pd.DataFrame(
1824+
... {
1825+
... "length": [1.5, 0.5, 1.2, 0.9, 3],
1826+
... "width": [0.7, 0.2, 0.15, 0.2, 1.1],
1827+
... },
1828+
... index=["pig", "rabbit", "duck", "chicken", "horse"],
1829+
... )
1830+
>>> plot = df.plot(title="DataFrame Plot")
1831+
1832+
For SeriesGroupBy:
1833+
1834+
.. plot::
1835+
:context: close-figs
1836+
1837+
>>> lst = [-1, -2, -3, 1, 2, 3]
1838+
>>> ser = pd.Series([1, 2, 2, 4, 6, 6], index=lst)
1839+
>>> plot = ser.groupby(lambda x: x > 0).plot(title="SeriesGroupBy Plot")
1840+
1841+
For DataFrameGroupBy:
1842+
1843+
.. plot::
1844+
:context: close-figs
1845+
1846+
>>> df = pd.DataFrame({"col1": [1, 2, 3, 4], "col2": ["A", "B", "A", "B"]})
1847+
>>> plot = df.groupby("col2").plot(kind="bar", title="DataFrameGroupBy Plot")
1848+
"""
16341849
result = GroupByPlot(self)
16351850
return result
16361851

0 commit comments

Comments
 (0)