Skip to content

Commit e9a6735

Browse files
dim1trijorisvandenbossche
authored andcommitted
DOC: update the pandas.DataFrame.plot.pie docstring (#20133)
1 parent 083ebac commit e9a6735

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

pandas/plotting/_core.py

+39-7
Original file line numberDiff line numberDiff line change
@@ -3133,19 +3133,51 @@ def area(self, x=None, y=None, **kwds):
31333133

31343134
def pie(self, y=None, **kwds):
31353135
"""
3136-
Pie chart
3136+
Generate a pie plot.
3137+
3138+
A pie plot is a proportional representation of the numerical data in a
3139+
column. This function wraps :meth:`matplotlib.pyplot.pie` for the
3140+
specified column. If no column reference is passed and
3141+
``subplots=True`` a pie plot is drawn for each numerical column
3142+
independently.
31373143
31383144
Parameters
31393145
----------
3140-
y : label or position, optional
3141-
Column to plot.
3142-
`**kwds` : optional
3143-
Additional keyword arguments are documented in
3144-
:meth:`pandas.DataFrame.plot`.
3146+
y : int or label, optional
3147+
Label or position of the column to plot.
3148+
If not provided, ``subplots=True`` argument must be passed.
3149+
**kwds
3150+
Keyword arguments to pass on to :meth:`pandas.DataFrame.plot`.
31453151
31463152
Returns
31473153
-------
3148-
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
3154+
axes : matplotlib.axes.Axes or np.ndarray of them.
3155+
A NumPy array is returned when `subplots` is True.
3156+
3157+
See Also
3158+
--------
3159+
Series.plot.pie : Generate a pie plot for a Series.
3160+
DataFrame.plot : Make plots of a DataFrame.
3161+
3162+
Examples
3163+
--------
3164+
In the example below we have a DataFrame with the information about
3165+
planet's mass and radius. We pass the the 'mass' column to the
3166+
pie function to get a pie plot.
3167+
3168+
.. plot::
3169+
:context: close-figs
3170+
3171+
>>> df = pd.DataFrame({'mass': [0.330, 4.87 , 5.97],
3172+
... 'radius': [2439.7, 6051.8, 6378.1]},
3173+
... index=['Mercury', 'Venus', 'Earth'])
3174+
>>> plot = df.plot.pie(y='mass', figsize=(5, 5))
3175+
3176+
.. plot::
3177+
:context: close-figs
3178+
3179+
>>> plot = df.plot.pie(subplots=True, figsize=(6, 3))
3180+
31493181
"""
31503182
return self(kind='pie', y=y, **kwds)
31513183

0 commit comments

Comments
 (0)