Skip to content

Commit 69455a4

Browse files
committed
DOC: update the DataFrame.plot.line docstring
1 parent 7c14e4f commit 69455a4

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

pandas/plotting/_core.py

+43-6
Original file line numberDiff line numberDiff line change
@@ -2704,18 +2704,55 @@ def __call__(self, x=None, y=None, kind='line', ax=None,
27042704

27052705
def line(self, x=None, y=None, **kwds):
27062706
"""
2707-
Line plot
2707+
Plot DataFrame columns as lines.
2708+
2709+
This function is useful to plot lines using DataFrame's values
2710+
as coordinates.
27082711
27092712
Parameters
27102713
----------
2711-
x, y : label or position, optional
2712-
Coordinates for each point.
2713-
`**kwds` : optional
2714-
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`.
2714+
x : int or str, optional
2715+
Columns to use for the horizontal axis.
2716+
Either the location or the label of the columns to be used.
2717+
By default, it will use the `DataFrame` indices.
2718+
y : int, str, or list of them, optional
2719+
The values to be plotted.
2720+
Either the location or the label of the columns to be used.
2721+
By default, it will use the remaining DataFrame numeric columns.
2722+
kwds : optional
2723+
Keyword arguments to pass on to :py:meth:pandas.DataFrame.plot.
27152724
27162725
Returns
27172726
-------
2718-
axes : matplotlib.AxesSubplot or np.array of them
2727+
axes : :class:matplotlib.AxesSubplot or :class:numpy.ndarray of
2728+
them.
2729+
2730+
See Also
2731+
--------
2732+
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.
2733+
2734+
Examples
2735+
--------
2736+
2737+
.. plot::
2738+
:context: close-figs
2739+
2740+
The following example shows the populations for some animals
2741+
over the years.
2742+
2743+
>>> df = pd.DataFrame({
2744+
... 'pig': [20, 18, 489, 675, 1776],
2745+
... 'horse': [4, 25, 281, 600, 1900]
2746+
... }, index=[1990, 1997, 2003, 2009, 2014])
2747+
>>> lines = df.plot.line()
2748+
2749+
.. plot::
2750+
:context: close-figs
2751+
2752+
The following example shows the relationship between both
2753+
populations.
2754+
2755+
>>> lines = df.plot.line(x='pig', y='horse')
27192756
"""
27202757
return self(kind='line', x=x, y=y, **kwds)
27212758

0 commit comments

Comments
 (0)