From ad5fb29f9c6852ebd7499c608c199d5773b42801 Mon Sep 17 00:00:00 2001 From: dim1tri Date: Sat, 10 Mar 2018 16:03:44 +0100 Subject: [PATCH 1/2] DOC: update the pandas.DataFrame.plot.pie docstring --- pandas/plotting/_core.py | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 98fdcf8f94ae0..8e176e8f93549 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2835,18 +2835,42 @@ def area(self, x=None, y=None, **kwds): def pie(self, y=None, **kwds): """ - Pie chart + Generate a pie plot. + + A pie plot is a representation of the distribution of numerical data + in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` + function for specified column. If no column reference is passed and + ``subplots`` argument is set to ``True``, an np.array of plots for + all DataFrame columns will be returned. Parameters ---------- - y : label or position, optional - Column to plot. - `**kwds` : optional + y : str or int, optional + Label or position of the column to plot. + If not provided, ``subplots=True`` argument must be passed. + **kwds : optional Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`. Returns ------- - axes : matplotlib.AxesSubplot or np.array of them + axes : matplotlib.AxesSubplot or np.array of them. + + See Also + -------- + :meth:`pandas.Series.plot.pie` : Generate a pie plot for a Series. + + Examples + -------- + In the example below we have a DataFrame with the information about + planet's mass and radius. We pass the the 'mass' column to the + pie function to get a pie plot. + + .. plot:: + :context: close-figs + + >>> df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97], + ... 'radius': [2439.7, 6051.8, 6378.1]}) + >>> plot = df.plot.pie(y='mass', labels=['Mercury', 'Venus', 'Earth']) """ return self(kind='pie', y=y, **kwds) From b7c98bb2b34623864d0c4e3f2afbf2975a503cae Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Fri, 16 Mar 2018 16:43:31 -0500 Subject: [PATCH 2/2] Updated [ci skip] * Aspect Ratio * Use index [ci skip] --- pandas/plotting/_core.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 8e176e8f93549..bb0c811d0c019 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2837,27 +2837,29 @@ def pie(self, y=None, **kwds): """ Generate a pie plot. - A pie plot is a representation of the distribution of numerical data - in a DataFrame column. This function wraps the `matplotlib.pyplot.pie` - function for specified column. If no column reference is passed and - ``subplots`` argument is set to ``True``, an np.array of plots for - all DataFrame columns will be returned. + A pie plot is a proportional representation of the numerical data in a + column. This function wraps :meth:`matplotlib.pyplot.pie` for the + specified column. If no column reference is passed and + ``subplots=True`` a pie plot is drawn for each numerical column + independently. Parameters ---------- - y : str or int, optional + y : int or label, optional Label or position of the column to plot. If not provided, ``subplots=True`` argument must be passed. - **kwds : optional - Keyword arguments to pass on to :py:meth:`pandas.DataFrame.plot`. + **kwds + Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`. Returns ------- - axes : matplotlib.AxesSubplot or np.array of them. + axes : matplotlib.axes.Axes or np.ndarray of them. + A NumPy array is returned when `subplots` is True. See Also -------- - :meth:`pandas.Series.plot.pie` : Generate a pie plot for a Series. + Series.plot.pie : Generate a pie plot for a Series. + DataFrame.plot : Make plots of a DataFrame. Examples -------- @@ -2869,8 +2871,15 @@ def pie(self, y=None, **kwds): :context: close-figs >>> df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97], - ... 'radius': [2439.7, 6051.8, 6378.1]}) - >>> plot = df.plot.pie(y='mass', labels=['Mercury', 'Venus', 'Earth']) + ... 'radius': [2439.7, 6051.8, 6378.1]}, + ... index=['Mercury', 'Venus', 'Earth']) + >>> plot = df.plot.pie(y='mass', figsize=(5, 5)) + + .. plot:: + :context: close-figs + + >>> plot = df.plot.pie(subplots=True, figsize=(6, 3)) + """ return self(kind='pie', y=y, **kwds)