Skip to content

DOC: update docs on direct plotting with matplotlib (GH8614) #8655

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

Closed
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
16 changes: 6 additions & 10 deletions doc/source/visualization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1566,15 +1566,11 @@ customization is not (yet) supported by pandas. Series and DataFrame objects
behave like arrays and can therefore be passed directly to matplotlib functions
without explicit casts.

pandas also automatically registers formatters and locators that recognize date
indices, thereby extending date and time support to practically all plot types
available in matplotlib. Although this formatting does not provide the same
level of refinement you would get when plotting via pandas, it can be faster
when plotting a large number of points.

.. note::

The speed up for large data sets only applies to pandas 0.14.0 and later.
Starting from pandas 0.15, you will need to use a ``to_pydatetime()``
Copy link
Member Author

Choose a reason for hiding this comment

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

"extending date and time support to practically all plot types available in matplotlib" -> @agijsberts but matplotlib by default has also a datetime converter?
https://github.com/matplotlib/matplotlib/blob/v1.4.2/lib/matplotlib/dates.py#L1380 We just overwrite it with ours?

call on the index in order to have matplotlib plot a ``DatetimeIndex`` as
dates.

.. ipython:: python
:suppress:
Expand All @@ -1590,10 +1586,10 @@ when plotting a large number of points.

plt.figure()

plt.plot(price.index, price, 'k')
plt.plot(ma.index, ma, 'b')
plt.plot(price.index.to_pydatetime(), price, 'k')
plt.plot(ma.index.to_pydatetime(), ma, 'b')
@savefig bollinger.png
plt.fill_between(mstd.index, ma-2*mstd, ma+2*mstd, color='b', alpha=0.2)
plt.fill_between(mstd.index.to_pydatetime(), ma-2*mstd, ma+2*mstd, color='b', alpha=0.2)

.. ipython:: python
:suppress:
Expand Down