Skip to content

Commit ab0272c

Browse files
committed
Merge pull request #6660 from agijsberts/docs-plot-with-mpl
DOC: Mention date and time formatting available throughout MPL
2 parents 7ffa655 + 767041a commit ab0272c

File tree

1 file changed

+47
-3
lines changed

1 file changed

+47
-3
lines changed

doc/source/visualization.rst

+47-3
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,18 @@ be colored differently.
651651
Colormaps
652652
~~~~~~~~~
653653

654-
A potential issue when plotting a large number of columns is that it can be difficult to distinguish some series due to repetition in the default colors. To remedy this, DataFrame plotting supports the use of the ``colormap=`` argument, which accepts either a Matplotlib `colormap <http://matplotlib.org/api/cm_api.html>`__ or a string that is a name of a colormap registered with Matplotlib. A visualization of the default matplotlib colormaps is available `here <http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps>`__.
655-
656-
As matplotlib does not directly support colormaps for line-based plots, the colors are selected based on an even spacing determined by the number of columns in the DataFrame. There is no consideration made for background color, so some colormaps will produce lines that are not easily visible.
654+
A potential issue when plotting a large number of columns is that it can be
655+
difficult to distinguish some series due to repetition in the default colors. To
656+
remedy this, DataFrame plotting supports the use of the ``colormap=`` argument,
657+
which accepts either a Matplotlib `colormap <http://matplotlib.org/api/cm_api.html>`__
658+
or a string that is a name of a colormap registered with Matplotlib. A
659+
visualization of the default matplotlib colormaps is available `here
660+
<http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps>`__.
661+
662+
As matplotlib does not directly support colormaps for line-based plots, the
663+
colors are selected based on an even spacing determined by the number of columns
664+
in the DataFrame. There is no consideration made for background color, so some
665+
colormaps will produce lines that are not easily visible.
657666

658667
To use the jet colormap, we can simply pass ``'jet'`` to ``colormap=``
659668

@@ -708,7 +717,42 @@ Andrews curves charts:
708717
@savefig andrews_curve_winter.png
709718
andrews_curves(data, 'Name', colormap='winter')
710719
720+
Plotting directly with matplotlib
721+
---------------------------------
722+
723+
In some situations it may still be preferable or necessary to prepare plots
724+
directly with matplotlib, for instance when a certain type of plot or
725+
customization is not (yet) supported by pandas. Series and DataFrame objects
726+
behave like arrays and can therefore be passed directly to matplotlib functions
727+
without explicit casts.
728+
729+
Pandas also automatically registers formatters and locators that recognize date
730+
indices, thereby extending date and time support to practically all plot types
731+
available in matplotlib. Although this formatting does not provide the same
732+
level of refinement you would get when plotting via pandas, it can be faster
733+
when plotting a large number of points.
734+
735+
.. note::
736+
737+
The speed up for large data sets only applies to pandas 0.14.0 and later.
738+
739+
740+
.. ipython:: python
741+
742+
price = Series(randn(150).cumsum(),
743+
index=date_range('2000-1-1', periods=150, freq='B'))
744+
ma = pd.rolling_mean(price, 20)
745+
mstd = pd.rolling_std(price, 20)
746+
747+
plt.figure()
748+
749+
plt.plot(price.index, price, 'k')
750+
plt.plot(ma.index, ma, 'b')
751+
@savefig bollinger.png
752+
plt.fill_between(mstd.index, ma-2*mstd, ma+2*mstd, color='b', alpha=0.2)
753+
711754
.. ipython:: python
712755
:suppress:
713756
714757
plt.close('all')
758+

0 commit comments

Comments
 (0)