DEPR: deprecate options.display.mpl_style · cldy/pandas@1c1b99e (original) (raw)

10 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -11,10 +11,7 @@
11 11 np.random.seed(123456)
12 12 np.set_printoptions(precision=4, suppress=True)
13 13 import matplotlib
14 - try:
15 - matplotlib.style.use('ggplot')
16 - except AttributeError:
17 - pd.options.display.mpl_style = 'default'
14 + matplotlib.style.use('ggplot')
18 15 pd.options.display.max_rows = 15
19 16
20 17 #### portions of this were borrowed from the
Original file line number Diff line number Diff line change
@@ -8,10 +8,7 @@
8 8 np.set_printoptions(precision=4, suppress=True)
9 9 import pandas as pd
10 10 import matplotlib
11 - try:
12 - matplotlib.style.use('ggplot')
13 - except AttributeError:
14 - pd.options.display.mpl_style = 'default'
11 + matplotlib.style.use('ggplot')
15 12 import matplotlib.pyplot as plt
16 13 plt.close('all')
17 14 pd.options.display.max_rows=15
Original file line number Diff line number Diff line change
@@ -19,10 +19,7 @@
19 19 pd.options.display.max_rows=15
20 20
21 21 import matplotlib
22 - try:
23 - matplotlib.style.use('ggplot')
24 - except AttributeError:
25 - pd.options.display.mpl_style = 'default'
22 + matplotlib.style.use('ggplot')
26 23
27 24 np.set_printoptions(precision=4, suppress=True)
28 25
Original file line number Diff line number Diff line change
@@ -14,10 +14,7 @@ Frequently Asked Questions (FAQ)
14 14 import pandas as pd
15 15 pd.options.display.max_rows = 15
16 16 import matplotlib
17 - try:
18 - matplotlib.style.use('ggplot')
19 - except AttributeError:
20 - pd.options.display.mpl_style = 'default'
17 + matplotlib.style.use('ggplot')
21 18 import matplotlib.pyplot as plt
22 19 plt.close('all')
23 20
Original file line number Diff line number Diff line change
@@ -10,10 +10,7 @@
10 10 import pandas as pd
11 11 pd.options.display.max_rows = 15
12 12 import matplotlib
13 - try:
14 - matplotlib.style.use('ggplot')
15 - except AttributeError:
16 - pd.options.display.mpl_style = 'default'
13 + matplotlib.style.use('ggplot')
17 14 import matplotlib.pyplot as plt
18 15 plt.close('all')
19 16
Original file line number Diff line number Diff line change
@@ -7,10 +7,7 @@
7 7 import pandas as pd
8 8 pd.options.display.max_rows=15
9 9 import matplotlib
10 - try:
11 - matplotlib.style.use('ggplot')
12 - except AttributeError:
13 - pd.options.display.mpl_style = 'default'
10 + matplotlib.style.use('ggplot')
14 11 import matplotlib.pyplot as plt
15 12
16 13 .. _missing_data:
Original file line number Diff line number Diff line change
@@ -361,12 +361,6 @@ display.max_seq_items 100 when pretty-printing a long sequence,
361 361 display.memory_usage True This specifies if the memory usage of
362 362 a DataFrame should be displayed when the
363 363 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.
370 364 display.multi_sparse True "Sparsify" MultiIndex display (don't
371 365 display repeated elements in outer
372 366 levels within groups)
Original file line number Diff line number Diff line change
@@ -816,6 +816,15 @@ Deprecations
816 816 - ``pandas.stats.ols``, ``pandas.stats.plm`` and ``pandas.stats.var`` routines are deprecated and will be removed in a future version (:issue:`6077`)
817 817 - 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`)
818 818
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 +
819 828 .. _whatsnew_0180.prior_deprecations:
820 829
821 830 Removal of prior version deprecations/changes
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
9 9 module is imported, register them here rather then in the module.
10 10
11 11 """
12 +import warnings
12 13
13 14 import pandas.core.config as cf
14 15 from pandas.core.config import (is_int, is_bool, is_text, is_instance_factory,
@@ -222,6 +223,11 @@
222 223 Setting this to None/False restores the values to their initial value.
223 224 """
224 225
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 +
225 231 pc_memory_usage_doc = """
226 232 : bool, string or None
227 233 This specifies if the memory usage of a DataFrame should be displayed when
@@ -246,6 +252,9 @@
246 252
247 253
248 254 def mpl_style_cb(key):
255 +warnings.warn(pc_mpl_style_deprecation_warning, FutureWarning,
256 +stacklevel=4)
257 +
249 258 import sys
250 259 from pandas.tools.plotting import mpl_stylesheet
251 260 global style_backup
Original file line number Diff line number Diff line change
@@ -3774,9 +3774,15 @@ def test_df_grid_settings(self):
3774 3774 plotting._dataframe_kinds, kws={'x': 'a', 'y': 'b'})
3775 3775
3776 3776 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)
3780 3786
3781 3787 with tm.assertRaises(ValueError):
3782 3788 set_option('display.mpl_style', 'default2')