Skip to content

DOC: update the DataFrame.plot.line docstring #20163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 12, 2018
Merged
59 changes: 52 additions & 7 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2759,19 +2759,64 @@ def __call__(self, x=None, y=None, kind='line', ax=None,

def line(self, x=None, y=None, **kwds):
"""
Line plot
Plot DataFrame columns as lines.

This function is useful to plot lines using DataFrame's values
as coordinates.

Parameters
----------
x, y : label or position, optional
Coordinates for each point.
`**kwds` : optional
Additional keyword arguments are documented in
:meth:`pandas.DataFrame.plot`.
x : int or str, optional
Columns to use for the horizontal axis.
Either the location or the label of the columns to be used.
By default, it will use the DataFrame indices.
y : int, str, or list of them, optional
The values to be plotted.
Either the location or the label of the columns to be used.
By default, it will use the remaining DataFrame numeric columns.
**kwds : optional
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 :class:`numpy.ndarray`
Returns an ndarray when ``subplots=True``.

See Also
--------
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.

Examples
--------

.. plot::
:context: close-figs

The following example shows the populations for some animals
over the years.

>>> df = pd.DataFrame({
... 'pig': [20, 18, 489, 675, 1776],
... 'horse': [4, 25, 281, 600, 1900]
... }, index=[1990, 1997, 2003, 2009, 2014])
>>> lines = df.plot.line()

.. plot::
:context: close-figs

An example with subplots, so an array of axes is returned.

>>> axes = df.plot.line(subplots=True)
>>> type(axes)
<class 'numpy.ndarray'>

.. plot::
:context: close-figs

The following example shows the relationship between both
populations.

>>> lines = df.plot.line(x='pig', y='horse')
"""
return self(kind='line', x=x, y=y, **kwds)

Expand Down