CLN: Check Warnings in test_graphics_others
State: closed

- [x] closes #13185 maybe
- [x] passes `git diff upstream/master | flake8 --diff`

Also a MatplotlibDeprecationWarning for use of `.get_axes()` vs. `.axes` in some tests.


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Visualization
description: plotting

Comments:
@neirbowj I don't know if this will fix your failing test or not, could you give it a shot? I think we have some assertions in here that depends on the test execution order :/

@TomAugspurger Yes, the tests are now passing. Thank you.

@TomAugspurger can you rebase this and see if you can fix the error?

Been trying to figure it out, but I can't get the error locally :/ I'll ping you when I get it sorted out.

@TomAugspurger ping :-)

## [Current coverage](https://codecov.io/gh/pydata/pandas/pull/13188?src=pr) is **84.33%**

> Merging [#13188](https://codecov.io/gh/pydata/pandas/pull/13188?src=pr) into [master](https://codecov.io/gh/pydata/pandas/branch/master?src=pr) will not change coverage

``` diff
@@             master     #13188   diff @@
==========================================
  Files           138        138          
  Lines         51111      51111          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
  Hits          43107      43107          
  Misses         8004       8004          
  Partials          0          0          
```

> Powered by [Codecov](https://codecov.io?src=pr). Last updated by [3944a36...b466fc1](https://codecov.io/gh/pydata/pandas/compare/3944a369265f27268d1b3867a161e97f9c63cd62...b466fc1437482d5ec5a74d9902968ff594fd7593)

Maybe you can put the second commit for mpl compat in a separate PR if that is less of a problem.

@jorisvandenbossche OK I'm giving up on this one I think :) Locally I get

```
nosetests pandas/tests/test_graphics_others.py:TestSeriesPlots.test_hist_layout_with_by
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
/Users/tom.augspurger/Envs/py3/lib/python3.5/site-packages/pandas/pandas/tools/plotting.py:2979: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  ylabelsize=ylabelsize, yrot=yrot, **kwds)
.
----------------------------------------------------------------------
Ran 1 test in 9.987s
```

Not really sure what about my environment that's different than Travis, but it's green now so I'm good with this if you are.

you need to run more tests - prob some other test is suppressing the warnings

keep running more and more till they fail 

`_check_plot_works` should be setting the warnings to always be raised. Some other tests were setting another filter, tried removing that, so we'll see.

@TomAugspurger The "UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared" you give is a very strange warning for that test, as there are no axes passed at all.

Translated, the test does this:

```
n = 100
gender = np.random.choice(['Male', 'Female'], size=n)
classroom = np.random.choice(['A', 'B', 'C'], size=n)
df = DataFrame({'gender': gender,
                'classroom': classroom,
                'height': np.random.normal(66, 4, size=n),
                'weight': np.random.normal(161, 32, size=n),
                'category': np.random.randint(4, size=n)})

axes = df.height.hist(by=df.gender, layout=(2, 1))
```

I do not get any warning for that locally if I run this in a console

I also get those warnings if I run that single test with nosetests. But I see that `_check_plot_works` does add an `ax` keyword to the kwargs. So that can explain the warnings of course

Ah, I didn't realize that `_check_plot_works` does that. I think refactoring that function to not do that would be difficult.

I can drop in some comments explaining what's going on.

@TomAugspurger I didn't know as well. Good idea to add some comments why the catching of a warning is needed, then this should be good to merge

@jorisvandenbossche this is ready to go in I think.

Merged!

@TomAugspurger Did it actually close #13185 ? (at the top, there is a 'maybe')