Skip to content

Commit c04b773

Browse files
DZPMTomAugspurger
authored andcommitted
DOC: update the pandas.DataFrame.plot.area docstring (#20170)
1 parent cc3ab4a commit c04b773

File tree

1 file changed

+73
-5
lines changed

1 file changed

+73
-5
lines changed

pandas/plotting/_core.py

+73-5
Original file line numberDiff line numberDiff line change
@@ -3337,19 +3337,87 @@ def kde(self, bw_method=None, ind=None, **kwds):
33373337

33383338
def area(self, x=None, y=None, **kwds):
33393339
"""
3340-
Area plot
3340+
Draw a stacked area plot.
3341+
3342+
An area plot displays quantitative data visually.
3343+
This function wraps the matplotlib area function.
33413344
33423345
Parameters
33433346
----------
3344-
x, y : label or position, optional
3345-
Coordinates for each point.
3346-
`**kwds` : optional
3347+
x : label or position, optional
3348+
Coordinates for the X axis. By default uses the index.
3349+
y : label or position, optional
3350+
Column to plot. By default uses all columns.
3351+
stacked : bool, default True
3352+
Area plots are stacked by default. Set to False to create a
3353+
unstacked plot.
3354+
**kwds : optional
33473355
Additional keyword arguments are documented in
33483356
:meth:`pandas.DataFrame.plot`.
33493357
33503358
Returns
33513359
-------
3352-
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
3360+
matplotlib.axes.Axes or numpy.ndarray
3361+
Area plot, or array of area plots if subplots is True
3362+
3363+
See Also
3364+
--------
3365+
DataFrame.plot : Make plots of DataFrame using matplotlib / pylab.
3366+
3367+
Examples
3368+
--------
3369+
Draw an area plot based on basic business metrics:
3370+
3371+
.. plot::
3372+
:context: close-figs
3373+
3374+
>>> df = pd.DataFrame({
3375+
... 'sales': [3, 2, 3, 9, 10, 6],
3376+
... 'signups': [5, 5, 6, 12, 14, 13],
3377+
... 'visits': [20, 42, 28, 62, 81, 50],
3378+
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
3379+
... freq='M'))
3380+
>>> ax = df.plot.area()
3381+
3382+
Area plots are stacked by default. To produce an unstacked plot,
3383+
pass ``stacked=False``:
3384+
3385+
.. plot::
3386+
:context: close-figs
3387+
3388+
>>> df = pd.DataFrame({
3389+
... 'sales': [3, 2, 3, 9, 10, 6],
3390+
... 'signups': [5, 5, 6, 12, 14, 13],
3391+
... 'visits': [20, 42, 28, 62, 81, 50],
3392+
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
3393+
... freq='M'))
3394+
>>> ax = df.plot.area(stacked=False)
3395+
3396+
Draw an area plot for each metric:
3397+
3398+
.. plot::
3399+
:context: close-figs
3400+
3401+
>>> df = pd.DataFrame({
3402+
... 'sales': [3, 2, 3, 9, 10, 6],
3403+
... 'signups': [5, 5, 6, 12, 14, 13],
3404+
... 'visits': [20, 42, 28, 62, 81, 50],
3405+
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
3406+
... freq='M'))
3407+
>>> ax = df.plot.area(y='sales')
3408+
3409+
Draw with a different `x`:
3410+
3411+
.. plot::
3412+
:context: close-figs
3413+
3414+
>>> df = pd.DataFrame({
3415+
... 'sales': [3, 2, 3],
3416+
... 'visits': [20, 42, 28],
3417+
... 'day': ['Monday', 'Tuesday', 'Wednesday'],
3418+
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
3419+
... freq='M'))
3420+
>>> ax = df.plot.area(x='day')
33533421
"""
33543422
return self(kind='area', x=x, y=y, **kwds)
33553423

0 commit comments

Comments
 (0)