Skip to content

DOC: fixes to DataFrame.plot.area docstring #22307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3385,25 +3385,13 @@ def area(self, x=None, y=None, **kwds):
.. plot::
:context: close-figs

>>> df = pd.DataFrame({
... 'sales': [3, 2, 3, 9, 10, 6],
... 'signups': [5, 5, 6, 12, 14, 13],
... 'visits': [20, 42, 28, 62, 81, 50],
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
... freq='M'))
>>> ax = df.plot.area(stacked=False)

Draw an area plot for each metric:
Draw an area plot for a single column:

.. plot::
:context: close-figs

>>> df = pd.DataFrame({
... 'sales': [3, 2, 3, 9, 10, 6],
... 'signups': [5, 5, 6, 12, 14, 13],
... 'visits': [20, 42, 28, 62, 81, 50],
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
... freq='M'))
>>> ax = df.plot.area(y='sales')

Draw with a different `x`:
Expand All @@ -3414,9 +3402,8 @@ def area(self, x=None, y=None, **kwds):
>>> df = pd.DataFrame({
... 'sales': [3, 2, 3],
... 'visits': [20, 42, 28],
... 'day': ['Monday', 'Tuesday', 'Wednesday'],
... }, index=pd.date_range(start='2018/01/01', end='2018/07/01',
... freq='M'))
... 'day': [1, 2, 3],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit unfortunate (because not that a useful example I think), but the string column did not work for me: it didn't add any actual labels to the x-axis.

... })
>>> ax = df.plot.area(x='day')
"""
return self(kind='area', x=x, y=y, **kwds)
Expand Down