Skip to content

Commit d122899

Browse files
committed
DOC: Improve docstring for pandas.DataFrame.plot.area
1 parent 5d661c8 commit d122899

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

pandas/plotting/_core.py

+71-5
Original file line numberDiff line numberDiff line change
@@ -3337,19 +3337,85 @@ 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+
Index, coordinates for X axis.
3349+
y : label or position, optional
3350+
Index, coordinates for Y axis.
3351+
stacked : boolean, 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+
pandas.DataFrame.plot : Draw plots.
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+
... })
3379+
>>> ax = df.plot.area()
3380+
3381+
Area plots are stacked by default. To produce an unstacked plot,
3382+
pass ``stacked=False``:
3383+
3384+
.. plot::
3385+
:context: close-figs
3386+
3387+
>>> df = pd.DataFrame({
3388+
... 'sales': [3, 2, 3, 9, 10, 6],
3389+
... 'signups': [5, 5, 6, 12, 14, 13],
3390+
... 'visits': [20, 42, 28, 62, 81, 50],
3391+
... })
3392+
>>> ax = df.plot.area(stacked=False)
3393+
3394+
Draw an area plot for each metric:
3395+
3396+
.. plot::
3397+
:context: close-figs
3398+
3399+
>>> df = pd.DataFrame({
3400+
... 'sales': [3, 2, 3, 9, 10, 6],
3401+
... 'signups': [5, 5, 6, 12, 14, 13],
3402+
... 'visits': [20, 42, 28, 62, 81, 50],
3403+
... })
3404+
>>> ax = df.plot.area(y='sales')
3405+
>>> ax = df.plot.area(y='signups')
3406+
>>> ax = df.plot.area(y='visits')
3407+
3408+
Draw with a different `x`:
3409+
3410+
.. plot::
3411+
:context: close-figs
3412+
3413+
>>> df = pd.DataFrame({
3414+
... 'sales': [3, 2, 3],
3415+
... 'visits': [20, 42, 28],
3416+
... 'day': ['Monday', 'Tuesday', 'Wednesday'],
3417+
... })
3418+
>>> ax = df.plot.area(x='day')
33533419
"""
33543420
return self(kind='area', x=x, y=y, **kwds)
33553421

0 commit comments

Comments
 (0)