Skip to content

Commit 5077a12

Browse files
committed
DOC: Improve docstring for pandas.DataFrame.plot.area
1 parent c36e9f7 commit 5077a12

File tree

1 file changed

+71
-5
lines changed

1 file changed

+71
-5
lines changed

pandas/plotting/_core.py

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,19 +3188,85 @@ def kde(self, bw_method=None, ind=None, **kwds):
31883188

31893189
def area(self, x=None, y=None, **kwds):
31903190
"""
3191-
Area plot
3191+
Draw a stacked area plot.
3192+
3193+
An area plot displays quantitative data visually.
3194+
This function wraps the matplotlib area function.
31923195
31933196
Parameters
31943197
----------
3195-
x, y : label or position, optional
3196-
Coordinates for each point.
3197-
`**kwds` : optional
3198+
x : label or position, optional
3199+
Index, coordinates for X axis.
3200+
y : label or position, optional
3201+
Index, coordinates for Y axis.
3202+
stacked : boolean, default True
3203+
Area plots are stacked by default. Set to False to create a
3204+
unstacked plot.
3205+
**kwds : optional
31983206
Additional keyword arguments are documented in
31993207
:meth:`pandas.DataFrame.plot`.
32003208
32013209
Returns
32023210
-------
3203-
axes : :class:`matplotlib.axes.Axes` or numpy.ndarray of them
3211+
matplotlib.axes.Axes or numpy.ndarray
3212+
Area plot, or array of area plots if subplots is True
3213+
3214+
See Also
3215+
--------
3216+
pandas.DataFrame.plot : Draw plots.
3217+
3218+
Examples
3219+
--------
3220+
Draw an area plot based on basic business metrics:
3221+
3222+
.. plot::
3223+
:context: close-figs
3224+
3225+
>>> df = pd.DataFrame({
3226+
... 'sales': [3, 2, 3, 9, 10, 6],
3227+
... 'signups': [5, 5, 6, 12, 14, 13],
3228+
... 'visits': [20, 42, 28, 62, 81, 50],
3229+
... })
3230+
>>> ax = df.plot.area()
3231+
3232+
Area plots are stacked by default. To produce an unstacked plot,
3233+
pass ``stacked=False``:
3234+
3235+
.. plot::
3236+
:context: close-figs
3237+
3238+
>>> df = pd.DataFrame({
3239+
... 'sales': [3, 2, 3, 9, 10, 6],
3240+
... 'signups': [5, 5, 6, 12, 14, 13],
3241+
... 'visits': [20, 42, 28, 62, 81, 50],
3242+
... })
3243+
>>> ax = df.plot.area(stacked=False)
3244+
3245+
Draw an area plot for each metric:
3246+
3247+
.. plot::
3248+
:context: close-figs
3249+
3250+
>>> df = pd.DataFrame({
3251+
... 'sales': [3, 2, 3, 9, 10, 6],
3252+
... 'signups': [5, 5, 6, 12, 14, 13],
3253+
... 'visits': [20, 42, 28, 62, 81, 50],
3254+
... })
3255+
>>> ax = df.plot.area(y='sales')
3256+
>>> ax = df.plot.area(y='signups')
3257+
>>> ax = df.plot.area(y='visits')
3258+
3259+
Draw with a different `x`:
3260+
3261+
.. plot::
3262+
:context: close-figs
3263+
3264+
>>> df = pd.DataFrame({
3265+
... 'sales': [3, 2, 3],
3266+
... 'visits': [20, 42, 28],
3267+
... 'day': ['Monday', 'Tuesday', 'Wednesday'],
3268+
... })
3269+
>>> ax = df.plot.area(x='day')
32043270
"""
32053271
return self(kind='area', x=x, y=y, **kwds)
32063272

0 commit comments

Comments
 (0)