Skip to content

Commit 9dc9f0c

Browse files
DOC: try to use matplotlib style (mpl >= 1.4) in all docs
1 parent 29377be commit 9dc9f0c

File tree

8 files changed

+34
-16
lines changed

8 files changed

+34
-16
lines changed

doc/source/10min.rst

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
from pandas import options
1313
import pandas as pd
1414
np.set_printoptions(precision=4, suppress=True)
15-
options.display.mpl_style='default'
15+
import matplotlib
16+
try:
17+
matplotlib.style.use('ggplot')
18+
except AttributeError:
19+
options.display.mpl_style = 'default'
1620
options.display.max_rows=15
1721
1822
#### portions of this were borrowed from the
@@ -695,8 +699,6 @@ Plotting
695699
696700
import matplotlib.pyplot as plt
697701
plt.close('all')
698-
from pandas import options
699-
options.display.mpl_style='default'
700702
701703
.. ipython:: python
702704

doc/source/categorical.rst

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from pandas import *
1414
import pandas as pd
1515
np.set_printoptions(precision=4, suppress=True)
16-
options.display.mpl_style='default'
1716
options.display.max_rows=15
1817
1918

doc/source/computation.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@
1010
import pandas.util.testing as tm
1111
randn = np.random.randn
1212
np.set_printoptions(precision=4, suppress=True)
13+
import matplotlib
14+
try:
15+
matplotlib.style.use('ggplot')
16+
except AttributeError:
17+
options.display.mpl_style = 'default'
1318
import matplotlib.pyplot as plt
1419
plt.close('all')
15-
options.display.mpl_style='default'
1620
options.display.max_rows=15
1721
1822
Computational tools

doc/source/cookbook.rst

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
np.random.seed(123456)
1818
1919
pd.options.display.max_rows=15
20-
pd.options.display.mpl_style='default'
20+
21+
import matplotlib
22+
try:
23+
matplotlib.style.use('ggplot')
24+
except AttributeError:
25+
pd.options.display.mpl_style = 'default'
2126
2227
np.set_printoptions(precision=4, suppress=True)
2328

doc/source/faq.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ Frequently Asked Questions (FAQ)
2121
from pandas.tseries.offsets import *
2222
import matplotlib.pyplot as plt
2323
plt.close('all')
24-
options.display.mpl_style='default'
24+
import matplotlib
25+
try:
26+
matplotlib.style.use('ggplot')
27+
except AttributeError:
28+
options.display.mpl_style = 'default'
2529
from pandas.compat import lrange
2630
2731

doc/source/groupby.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
np.set_printoptions(precision=4, suppress=True)
1313
import matplotlib.pyplot as plt
1414
plt.close('all')
15-
options.display.mpl_style='default'
15+
import matplotlib
16+
try:
17+
matplotlib.style.use('ggplot')
18+
except AttributeError:
19+
options.display.mpl_style = 'default'
1620
from pandas.compat import zip
1721
1822
*****************************
@@ -346,7 +350,7 @@ A single group can be selected using ``GroupBy.get_group()``:
346350
.. ipython:: python
347351
348352
grouped.get_group('bar')
349-
353+
350354
Or for an object grouped on multiple columns:
351355

352356
.. ipython:: python

doc/source/sparse.rst

-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import pandas.util.testing as tm
1111
randn = np.random.randn
1212
np.set_printoptions(precision=4, suppress=True)
13-
import matplotlib.pyplot as plt
14-
plt.close('all')
15-
options.display.mpl_style='default'
1613
options.display.max_rows = 15
1714
1815
**********************
@@ -222,4 +219,3 @@ row and columns coordinates of the matrix. Note that this will consume a signifi
222219
223220
ss_dense = SparseSeries.from_coo(A, dense_index=True)
224221
ss_dense
225-

doc/source/visualization.rst

+7-3
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,14 @@ We use the standard convention for referencing the matplotlib API:
3131
3232
import matplotlib.pyplot as plt
3333
34-
.. versionadded:: 0.11.0
34+
The plots in this document are made using matplotlib's ``ggplot`` style (new in version 1.4):
3535

36-
The plots in this document are made using matplotlib's ``ggplot`` style (new in version 1.4).
37-
If your version of matplotlib is 1.3 or lower, setting the ``display.mpl_style`` to ``'default'``
36+
.. code-block:: python
37+
38+
import matplotlib
39+
matplotlib.style.use('ggplot')
40+
41+
If your version of matplotlib is 1.3 or lower, you can set ``display.mpl_style`` to ``'default'``
3842
with ``pd.options.display.mpl_style = 'default'``
3943
to produce more appealing plots.
4044
When set, matplotlib's ``rcParams`` are changed (globally!) to nicer-looking settings.

0 commit comments

Comments
 (0)