Skip to content

Commit 1c1b99e

Browse files
committed
DEPR: deprecate options.display.mpl_style
Closes #11783
1 parent 4404d39 commit 1c1b99e

File tree

10 files changed

+33
-33
lines changed

10 files changed

+33
-33
lines changed

doc/source/10min.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111
np.random.seed(123456)
1212
np.set_printoptions(precision=4, suppress=True)
1313
import matplotlib
14-
try:
15-
matplotlib.style.use('ggplot')
16-
except AttributeError:
17-
pd.options.display.mpl_style = 'default'
14+
matplotlib.style.use('ggplot')
1815
pd.options.display.max_rows = 15
1916
2017
#### portions of this were borrowed from the

doc/source/computation.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
np.set_printoptions(precision=4, suppress=True)
99
import pandas as pd
1010
import matplotlib
11-
try:
12-
matplotlib.style.use('ggplot')
13-
except AttributeError:
14-
pd.options.display.mpl_style = 'default'
11+
matplotlib.style.use('ggplot')
1512
import matplotlib.pyplot as plt
1613
plt.close('all')
1714
pd.options.display.max_rows=15

doc/source/cookbook.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@
1919
pd.options.display.max_rows=15
2020
2121
import matplotlib
22-
try:
23-
matplotlib.style.use('ggplot')
24-
except AttributeError:
25-
pd.options.display.mpl_style = 'default'
22+
matplotlib.style.use('ggplot')
2623
2724
np.set_printoptions(precision=4, suppress=True)
2825

doc/source/faq.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@ Frequently Asked Questions (FAQ)
1414
import pandas as pd
1515
pd.options.display.max_rows = 15
1616
import matplotlib
17-
try:
18-
matplotlib.style.use('ggplot')
19-
except AttributeError:
20-
pd.options.display.mpl_style = 'default'
17+
matplotlib.style.use('ggplot')
2118
import matplotlib.pyplot as plt
2219
plt.close('all')
2320

doc/source/groupby.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import pandas as pd
1111
pd.options.display.max_rows = 15
1212
import matplotlib
13-
try:
14-
matplotlib.style.use('ggplot')
15-
except AttributeError:
16-
pd.options.display.mpl_style = 'default'
13+
matplotlib.style.use('ggplot')
1714
import matplotlib.pyplot as plt
1815
plt.close('all')
1916

doc/source/missing_data.rst

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
import pandas as pd
88
pd.options.display.max_rows=15
99
import matplotlib
10-
try:
11-
matplotlib.style.use('ggplot')
12-
except AttributeError:
13-
pd.options.display.mpl_style = 'default'
10+
matplotlib.style.use('ggplot')
1411
import matplotlib.pyplot as plt
1512
1613
.. _missing_data:

doc/source/options.rst

-6
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,6 @@ display.max_seq_items 100 when pretty-printing a long sequence,
361361
display.memory_usage True This specifies if the memory usage of
362362
a DataFrame should be displayed when the
363363
df.info() method is invoked.
364-
display.mpl_style None Setting this to 'default' will modify
365-
the rcParams used by matplotlib
366-
to give plots a more pleasing visual
367-
style by default. Setting this to
368-
None/False restores the values to
369-
their initial value.
370364
display.multi_sparse True "Sparsify" MultiIndex display (don't
371365
display repeated elements in outer
372366
levels within groups)

doc/source/whatsnew/v0.18.0.txt

+9
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,15 @@ Deprecations
816816
- ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var`` routines are deprecated and will be removed in a future version (:issue:`6077`)
817817
- show a ``FutureWarning`` rather than a ``DeprecationWarning`` on using long-time deprecated syntax in ``HDFStore.select``, where the ``where`` clause is not a string-like (:issue:`12027`)
818818

819+
- The ``pandas.options.display.mpl_style`` configuration has been deprecated
820+
and will be removed in a future version of pandas. This functionality
821+
is better handled by matplotlib's `style sheets`_ (:issue:`11783`).
822+
823+
824+
825+
826+
.. _style sheets: http://matplotlib.org/users/style_sheets.html
827+
819828
.. _whatsnew_0180.prior_deprecations:
820829

821830
Removal of prior version deprecations/changes

pandas/core/config_init.py

+9
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
module is imported, register them here rather then in the module.
1010
1111
"""
12+
import warnings
1213

1314
import pandas.core.config as cf
1415
from pandas.core.config import (is_int, is_bool, is_text, is_instance_factory,
@@ -222,6 +223,11 @@
222223
Setting this to None/False restores the values to their initial value.
223224
"""
224225

226+
pc_mpl_style_deprecation_warning = """
227+
mpl_style had been deprecated and will be removed in a future version.
228+
Use `matplotlib.pyplot.style.use` instead.
229+
"""
230+
225231
pc_memory_usage_doc = """
226232
: bool, string or None
227233
This specifies if the memory usage of a DataFrame should be displayed when
@@ -246,6 +252,9 @@
246252

247253

248254
def mpl_style_cb(key):
255+
warnings.warn(pc_mpl_style_deprecation_warning, FutureWarning,
256+
stacklevel=4)
257+
249258
import sys
250259
from pandas.tools.plotting import mpl_stylesheet
251260
global style_backup

pandas/tests/test_graphics.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -3774,9 +3774,15 @@ def test_df_grid_settings(self):
37743774
plotting._dataframe_kinds, kws={'x': 'a', 'y': 'b'})
37753775

37763776
def test_option_mpl_style(self):
3777-
set_option('display.mpl_style', 'default')
3778-
set_option('display.mpl_style', None)
3779-
set_option('display.mpl_style', False)
3777+
with tm.assert_produces_warning(FutureWarning,
3778+
check_stacklevel=False):
3779+
set_option('display.mpl_style', 'default')
3780+
with tm.assert_produces_warning(FutureWarning,
3781+
check_stacklevel=False):
3782+
set_option('display.mpl_style', None)
3783+
with tm.assert_produces_warning(FutureWarning,
3784+
check_stacklevel=False):
3785+
set_option('display.mpl_style', False)
37803786

37813787
with tm.assertRaises(ValueError):
37823788
set_option('display.mpl_style', 'default2')

0 commit comments

Comments
 (0)