Skip to content

Commit 5d35f0f

Browse files
ifoschTomAugspurger
authored andcommitted
DOC: update the DataFrame.plot.line docstring (#20163)
* DOC: update the DataFrame.plot.line docstring * Minor cleanup * kwds * Removed kwargs type [ci skip]
1 parent f85ae92 commit 5d35f0f

File tree

1 file changed

+52
-7
lines changed

1 file changed

+52
-7
lines changed

pandas/plotting/_core.py

+52-7
Original file line numberDiff line numberDiff line change
@@ -2772,19 +2772,64 @@ def __call__(self, x=None, y=None, kind='line', ax=None,
27722772

27732773
def line(self, x=None, y=None, **kwds):
27742774
"""
2775-
Line plot
2775+
Plot DataFrame columns as lines.
2776+
2777+
This function is useful to plot lines using DataFrame's values
2778+
as coordinates.
27762779
27772780
Parameters
27782781
----------
2779-
x, y : label or position, optional
2780-
Coordinates for each point.
2781-
`**kwds` : optional
2782-
Additional keyword arguments are documented in
2783-
:meth:`pandas.DataFrame.plot`.
2782+
x : int or str, optional
2783+
Columns to use for the horizontal axis.
2784+
Either the location or the label of the columns to be used.
2785+
By default, it will use the DataFrame indices.
2786+
y : int, str, or list of them, optional
2787+
The values to be plotted.
2788+
Either the location or the label of the columns to be used.
2789+
By default, it will use the remaining DataFrame numeric columns.
2790+
**kwds
2791+
Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`.
27842792
27852793
Returns
27862794
-------
2787-
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
2795+
axes : :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray`
2796+
Returns an ndarray when ``subplots=True``.
2797+
2798+
See Also
2799+
--------
2800+
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.
2801+
2802+
Examples
2803+
--------
2804+
2805+
.. plot::
2806+
:context: close-figs
2807+
2808+
The following example shows the populations for some animals
2809+
over the years.
2810+
2811+
>>> df = pd.DataFrame({
2812+
... 'pig': [20, 18, 489, 675, 1776],
2813+
... 'horse': [4, 25, 281, 600, 1900]
2814+
... }, index=[1990, 1997, 2003, 2009, 2014])
2815+
>>> lines = df.plot.line()
2816+
2817+
.. plot::
2818+
:context: close-figs
2819+
2820+
An example with subplots, so an array of axes is returned.
2821+
2822+
>>> axes = df.plot.line(subplots=True)
2823+
>>> type(axes)
2824+
<class 'numpy.ndarray'>
2825+
2826+
.. plot::
2827+
:context: close-figs
2828+
2829+
The following example shows the relationship between both
2830+
populations.
2831+
2832+
>>> lines = df.plot.line(x='pig', y='horse')
27882833
"""
27892834
return self(kind='line', x=x, y=y, **kwds)
27902835

0 commit comments

Comments
 (0)