From 69455a4d88153084fbced9e45c6c44f1a41d6cd2 Mon Sep 17 00:00:00 2001 From: Ignasi Fosch Date: Sat, 10 Mar 2018 15:45:37 +0100 Subject: [PATCH 1/4] DOC: update the DataFrame.plot.line docstring --- pandas/plotting/_core.py | 49 +++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 98fdcf8f94ae0..e5e2529cb3d3a 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2704,18 +2704,55 @@ 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 - Keyword arguments to pass on to :py: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 :py:meth:pandas.DataFrame.plot. Returns ------- - axes : matplotlib.AxesSubplot or np.array of them + axes : :class:matplotlib.AxesSubplot or :class:numpy.ndarray of + them. + + 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 + + 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) From 7abe1eed1211e59d099e058691a058d9a51e0c47 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sun, 11 Mar 2018 07:20:08 -0500 Subject: [PATCH 2/4] Minor cleanup --- pandas/plotting/_core.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index e5e2529cb3d3a..520c9eed00e5d 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2714,18 +2714,18 @@ def line(self, x=None, y=None, **kwds): 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. + 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 :py:meth:pandas.DataFrame.plot. + Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`. Returns ------- - axes : :class:matplotlib.AxesSubplot or :class:numpy.ndarray of - them. + axes : :class:`matplotlib.axes.Axes` or :class:`numpy.ndarray` + Returns an ndarray when ``subplots=True``. See Also -------- @@ -2746,6 +2746,15 @@ def line(self, x=None, y=None, **kwds): ... }, 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) + + .. plot:: :context: close-figs From dc1eeb74c85d6597392f7561681fce5a28f4e3d3 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Sun, 11 Mar 2018 07:24:10 -0500 Subject: [PATCH 3/4] kwds --- pandas/plotting/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 1291d8b4fc76c..86719967c0d2c 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2774,7 +2774,7 @@ def line(self, x=None, y=None, **kwds): 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 + **kwds : optional Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`. Returns From 75b1a2226474d1f3f9db54f98e493bec3790f9b2 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 12 Mar 2018 07:02:05 -0500 Subject: [PATCH 4/4] Removed kwargs type [ci skip] --- pandas/plotting/_core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 08e4f3f0606fb..2c2521ad50ce0 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2787,7 +2787,7 @@ def line(self, x=None, y=None, **kwds): 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 + **kwds Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`. Returns