DEPR: deprecate options.display.mpl_style
State: closed

Closes https://github.com/pydata/pandas/issues/11783

Deprecates pd.options.display.mpl_style in favor of matplotlib's style sheets.


Labels:
name: Visualization
description: plotting
name: Deprecate
description: Functionality to remove in pandas

Comments:
Repushed with changes to not use the deprecation stuff that's already in `pandas/core/config.py` I think that's more for deprecating keywords than entire options but I might have been misusing it.

you have to do this differently there is a way to deprecate an option directly - look in config.py

I think that was our way around `DeprecationWarning` not actually warning :) Maybe should be a FutureWarning, but probably not worth the change.

Anyway the other warnings are only printed once. Mine gets printed twice since it has a callback associated. I'll see what I can tweak in the callback to make it not be printed twice.

@TomAugspurger ok sure np

Ok, I just put the deprecation warning inside the callback and we're all good.

```
In [1]: pd.options.display.mpl_style = False

mpl_style had been deprecated. Use `matplotlib.pyplot.style.use` instead.
```

Are you could with slating it for 0.19?

EDIT: Nevermind this fails if you toggle the option more than once.
EDIT2: Ok, not sure there's a way to elegantly use the deprecation system in `core/confing.py` on an option with a callback. Right now it works correctly the first time, and the prints twice for each additional time you toggle it. I can keep messing if you want, but I'd rather work on other things now :)

I think need to catch all of the uses of this deprecation in `assert_produces_warning(DeprecationWarning, check_stacklevel=False)` 

```
======================================================================
FAIL: test_option_mpl_style (pandas.tests.test_graphics.TestDataFramePlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/pydata/pandas/pandas/tests/test_graphics.py", line 3781, in test_option_mpl_style
    set_option('display.mpl_style', False)
  File "/home/travis/miniconda/envs/pandas/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/home/travis/build/pydata/pandas/pandas/util/testing.py", line 2099, in assert_produces_warning
    % expected_warning.__name__)
AssertionError: Did not see expected warning of class 'DeprecationWarning'.
```

> When should we actually remove? I'd say 0.19.

I vote after someone commits an equivalent stylesheet to the MPL repo. It's a good stylesheet and breaking without having an alternate will suck.

I'm guessing they would accept a patch if you want to submit one.

FWIW, you can define your own and pass a path to [`plt.use`](http://matplotlib.org/users/style_sheets.html#defining-your-own-style).  The params for this one are [here](https://github.com/pydata/pandas/blob/62363d2ff2079f4c7e0cc69b0a9dc4dc579a5bd3/pandas/tools/plotting.py#L33)

I think the style actually already exists in matplotlib as the `bmh` style (based on the style in the Bayesian methods for hackers book). See this example: http://matplotlib.org/examples/style_sheets/plot_bmh.html (only the font type seems different, if I recall the pandas 'default' style correctly)

@brian-pantano Would you be able to test that this is indeed a very similar style?

Because in that case, it would maybe be good to mention that in the deprecation warning

@TomAugspurger can you update

Anyone have guesses why https://travis-ci.org/pydata/pandas/jobs/108193241 would be failing to produce the DeprecationWarning? Strangely the `print` to stdout shows up, but the DeprecationWarning apparently isn't issued.

If no one knows what's going on, I'll just change back to putting the DeprecationWarning in the function that does the update itself.

I couldn't reproduce the failure due to not warning in https://travis-ci.org/pydata/pandas/jobs/108193241 locally, so I reimplemented it to just issue a FutureWarning in the function that updates the params. This is better anyway since it's actually a warning (and not printing to stdout) and it doesn't print twice anymore. OK with that?

very minor comments. merge when ready.