Skip to content

Commit b58be42

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

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

pandas/plotting/_core.py

+43-5
Original file line numberDiff line numberDiff line change
@@ -2704,18 +2704,56 @@ 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.
2711+
It allows to specify which columns to use for the axes.
27082712
27092713
Parameters
27102714
----------
2711-
x, y : label or position, optional
2712-
Coordinates for each point.
2713-
`**kwds` : optional
2715+
x : int, str, list of int or list of str, optional
2716+
It defines the X axis coordinates.
2717+
Either the location or the label of the columns to be used.
2718+
By default, it will use the `DataFrame` indices.
2719+
y : int, str, list of int or list of str, optional
2720+
It defines the values to be plotted.
2721+
Either the location or the label of the columns to be used.
2722+
By default, it will use the remaining `DataFrame` columns.
2723+
kwds : optional
27142724
Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`.
27152725
27162726
Returns
27172727
-------
2718-
axes : matplotlib.AxesSubplot or np.array of them
2728+
axes : :class:`matplotlib.AxesSubplot` or :meth:`np.array` of
2729+
them.
2730+
2731+
See Also
2732+
--------
2733+
matplotlib.pyplot.plot : Plot y versus x as lines and/or markers.
2734+
2735+
Examples
2736+
--------
2737+
2738+
.. plot::
2739+
:context: close-figs
2740+
2741+
The following example shows the populations for some animals
2742+
over the years.
2743+
2744+
>>> df = pd.DataFrame({
2745+
... 'pig': [20, 18, 489, 675, 1776],
2746+
... 'horse': [4, 25, 281, 600, 1900]
2747+
... }, index=[1990, 1997, 2003, 2009, 2014])
2748+
>>> lines = df.plot.line()
2749+
2750+
.. plot::
2751+
:context: close-figs
2752+
2753+
The following example shows the relationship between both
2754+
populations.
2755+
2756+
>>> lines = df.plot.line('pig', 'horse')
27192757
"""
27202758
return self(kind='line', x=x, y=y, **kwds)
27212759

0 commit comments

Comments
 (0)