Repository: pandas-dev/pandas

Issue:
FAIL: test_scatter_matrix_axis (pandas.tests.test_graphics_others.TestDataFramePlots) in 0.18.1 with py27
When run alone, `test_scatter_matrix_axis` passes. When run together with the rest of `TestDataFramePlots`, it fails.

I cannot test with py34 because matplotlib is not available on FreeBSD under py3k.
#### Code Sample, a copy-pastable example if possible

```
% nosetests-2.7 pandas.tests.test_graphics_others:TestDataFramePlots.test_scatter_matrix_axis
.
----------------------------------------------------------------------
Ran 1 test in 8.150s

OK
% nosetests-2.7 pandas.tests.test_graphics_others:TestDataFramePlots
..S/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
/usr/local/lib/python2.7/site-packages/matplotlib/artist.py:221: MatplotlibDeprecationWarning: This has been deprecated in mpl 1.5, please use the
axes property.  A removal date has not been set.
  warnings.warn(_get_axes_msg, mplDeprecation, stacklevel=1)
/usr/local/lib/python2.7/site-packages/pandas/tools/plotting.py:3369: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared
  "the passed axes is being cleared", UserWarning)
......F.
======================================================================
FAIL: test_scatter_matrix_axis (pandas.tests.test_graphics_others.TestDataFramePlots)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/pandas/tests/test_graphics_others.py", line 431, in test_scatter_matrix_axis
    frame=df, range_padding=.1)
  File "/usr/local/lib/python2.7/contextlib.py", line 24, in __exit__
    self.gen.next()
  File "/usr/local/lib/python2.7/site-packages/pandas/util/testing.py", line 2318, in assert_produces_warning
    % expected_warning.__name__)
AssertionError: Did not see expected warning of class 'UserWarning'.

----------------------------------------------------------------------
Ran 11 tests in 74.896s

FAILED (SKIP=1, failures=1)
```
#### Expected Output

I expect all tests to pass.
#### output of `pd.show_versions()`

```
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.11.final.0
python-bits: 64
OS: FreeBSD
OS-release: 10.2-STABLE
machine: amd64
processor: amd64
byteorder: little
LC_ALL: None
LANG: None

pandas: 0.18.1
nose: 1.3.7
pip: 8.0.2
setuptools: 20.0
Cython: None
numpy: 1.11.0
scipy: 0.16.1
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.0
pytz: 2016.4
blosc: None
bottleneck: 1.0.0
tables: 3.2.2
numexpr: 2.5.2
matplotlib: 1.5.0
openpyxl: 2.3.5
xlrd: 0.9.3
xlwt: 0.7.5
xlsxwriter: 0.8.5
lxml: 3.5.0
bs4: 4.4.1
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: 0.7.10
pymysql: None
psycopg2: None
jinja2: 2.8
boto: 2.39.0
pandas_datareader: None
```



Discussion:
Thanks. Haven't been able to reproduce yet, but I'm going to clean up that testing module anyway to catch all those userwarnings and fix the matplotlib deprecation warning. Hopefully I'll figure out what's going wrong.


Resolving patch:
diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py
--- a/pandas/tools/plotting.py
+++ b/pandas/tools/plotting.py
@@ -3353,7 +3353,8 @@ def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True,
             if sharex or sharey:
                 warnings.warn("When passing multiple axes, sharex and sharey "
                               "are ignored. These settings must be specified "
-                              "when creating axes", UserWarning)
+                              "when creating axes", UserWarning,
+                              stacklevel=4)
             if len(ax) == naxes:
                 fig = ax[0].get_figure()
                 return fig, ax
@@ -3370,7 +3371,8 @@ def _subplots(naxes=None, sharex=False, sharey=False, squeeze=True,
                 return fig, _flatten(ax)
         else:
             warnings.warn("To output multiple subplots, the figure containing "
-                          "the passed axes is being cleared", UserWarning)
+                          "the passed axes is being cleared", UserWarning,
+                          stacklevel=4)
             fig.clear()
 
     nrows, ncols = _get_layout(naxes, layout=layout, layout_type=layout_type)


Test patch:
diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py
--- a/pandas/tests/test_graphics.py
+++ b/pandas/tests/test_graphics.py
@@ -450,8 +450,9 @@ def _check_box_return_type(self, returned, return_type, expected_keys=None,
                     self.assertIsInstance(value.lines, dict)
                 elif return_type == 'dict':
                     line = value['medians'][0]
+                    axes = line.axes if self.mpl_ge_1_5_0 else line.get_axes()
                     if check_ax_title:
-                        self.assertEqual(line.get_axes().get_title(), key)
+                        self.assertEqual(axes.get_title(), key)
                 else:
                     raise AssertionError
 
@@ -820,10 +821,13 @@ def test_hist_legacy(self):
         _check_plot_works(self.ts.hist)
         _check_plot_works(self.ts.hist, grid=False)
         _check_plot_works(self.ts.hist, figsize=(8, 10))
-        _check_plot_works(self.ts.hist, filterwarnings='ignore',
-                          by=self.ts.index.month)
-        _check_plot_works(self.ts.hist, filterwarnings='ignore',
-                          by=self.ts.index.month, bins=5)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(self.ts.hist,
+                              by=self.ts.index.month)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(self.ts.hist,
+                              by=self.ts.index.month, bins=5)
 
         fig, ax = self.plt.subplots(1, 1)
         _check_plot_works(self.ts.hist, ax=ax)
@@ -857,32 +861,40 @@ def test_hist_layout(self):
     def test_hist_layout_with_by(self):
         df = self.hist_df
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.gender, layout=(2, 1))
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.gender, layout=(2, 1))
         self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.gender, layout=(3, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.gender, layout=(3, -1))
         self._check_axes_shape(axes, axes_num=2, layout=(3, 1))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.category, layout=(4, 1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.category, layout=(4, 1))
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.category, layout=(2, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.category, layout=(2, -1))
         self._check_axes_shape(axes, axes_num=4, layout=(2, 2))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.category, layout=(3, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.category, layout=(3, -1))
         self._check_axes_shape(axes, axes_num=4, layout=(3, 2))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.category, layout=(-1, 4))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.category, layout=(-1, 4))
         self._check_axes_shape(axes, axes_num=4, layout=(1, 4))
 
-        axes = _check_plot_works(df.height.hist, filterwarnings='ignore',
-                                 by=df.classroom, layout=(2, 2))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist,
+                                     by=df.classroom, layout=(2, 2))
         self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
 
         axes = df.height.hist(by=df.category, layout=(4, 2), figsize=(12, 7))
@@ -899,7 +911,7 @@ def test_hist_no_overlap(self):
         subplot(122)
         y.hist()
         fig = gcf()
-        axes = fig.get_axes()
+        axes = fig.axes if self.mpl_ge_1_5_0 else fig.get_axes()
         self.assertEqual(len(axes), 2)
 
     @slow
@@ -1300,17 +1312,21 @@ def setUp(self):
     @slow
     def test_plot(self):
         df = self.tdf
-        _check_plot_works(df.plot, filterwarnings='ignore', grid=False)
-        axes = _check_plot_works(df.plot, filterwarnings='ignore',
-                                 subplots=True)
+        _check_plot_works(df.plot, grid=False)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot,
+                                     subplots=True)
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
-        axes = _check_plot_works(df.plot, filterwarnings='ignore',
-                                 subplots=True, layout=(-1, 2))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot,
+                                     subplots=True, layout=(-1, 2))
         self._check_axes_shape(axes, axes_num=4, layout=(2, 2))
 
-        axes = _check_plot_works(df.plot, filterwarnings='ignore',
-                                 subplots=True, use_index=False)
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot,
+                                     subplots=True, use_index=False)
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
         df = DataFrame({'x': [1, 2], 'y': [3, 4]})
@@ -1326,8 +1342,8 @@ def test_plot(self):
         _check_plot_works(df.plot, xticks=[1, 5, 10])
         _check_plot_works(df.plot, ylim=(-100, 100), xlim=(-100, 100))
 
-        _check_plot_works(df.plot, filterwarnings='ignore',
-                          subplots=True, title='blah')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.plot, subplots=True, title='blah')
 
         # We have to redo it here because _check_plot_works does two plots,
         # once without an ax kwarg and once with an ax kwarg and the new sharex
@@ -2217,7 +2233,9 @@ def test_plot_bar(self):
 
         _check_plot_works(df.plot.bar)
         _check_plot_works(df.plot.bar, legend=False)
-        _check_plot_works(df.plot.bar, filterwarnings='ignore', subplots=True)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.plot.bar, subplots=True)
         _check_plot_works(df.plot.bar, stacked=True)
 
         df = DataFrame(randn(10, 15),
@@ -2433,8 +2451,10 @@ def test_boxplot_vertical(self):
         self._check_text_labels(ax.get_yticklabels(), labels)
         self.assertEqual(len(ax.lines), self.bp_n_objects * len(numeric_cols))
 
-        axes = _check_plot_works(df.plot.box, filterwarnings='ignore',
-                                 subplots=True, vert=False, logx=True)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot.box,
+                                     subplots=True, vert=False, logx=True)
         self._check_axes_shape(axes, axes_num=3, layout=(1, 3))
         self._check_ax_scales(axes, xaxis='log')
         for ax, label in zip(axes, labels):
@@ -2494,8 +2514,9 @@ def test_kde_df(self):
         ax = df.plot(kind='kde', rot=20, fontsize=5)
         self._check_ticks_props(ax, xrot=20, xlabelsize=5, ylabelsize=5)
 
-        axes = _check_plot_works(df.plot, filterwarnings='ignore', kind='kde',
-                                 subplots=True)
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot, kind='kde',
+                                     subplots=True)
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
         axes = df.plot(kind='kde', logy=True, subplots=True)
@@ -2522,8 +2543,9 @@ def test_hist_df(self):
         expected = [pprint_thing(c) for c in df.columns]
         self._check_legend_labels(ax, labels=expected)
 
-        axes = _check_plot_works(df.plot.hist, filterwarnings='ignore',
-                                 subplots=True, logy=True)
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot.hist,
+                                     subplots=True, logy=True)
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
         self._check_ax_scales(axes, yaxis='log')
 
@@ -2902,8 +2924,9 @@ def test_line_colors_and_styles_subplots(self):
             # Color contains shorthand hex value results in ValueError
             custom_colors = ['#F00', '#00F', '#FF0', '#000', '#FFF']
             # Forced show plot
-            _check_plot_works(df.plot, color=custom_colors, subplots=True,
-                              filterwarnings='ignore')
+            # _check_plot_works adds an ax so catch warning. see GH #13188
+            with tm.assert_produces_warning(UserWarning):
+                _check_plot_works(df.plot, color=custom_colors, subplots=True)
 
         rgba_colors = lmap(cm.jet, np.linspace(0, 1, len(df)))
         for cmap in ['jet', cm.jet]:
@@ -3294,8 +3317,10 @@ def test_pie_df(self):
         ax = _check_plot_works(df.plot.pie, y=2)
         self._check_text_labels(ax.texts, df.index)
 
-        axes = _check_plot_works(df.plot.pie, filterwarnings='ignore',
-                                 subplots=True)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot.pie,
+                                     subplots=True)
         self.assertEqual(len(axes), len(df.columns))
         for ax in axes:
             self._check_text_labels(ax.texts, df.index)
@@ -3304,9 +3329,10 @@ def test_pie_df(self):
 
         labels = ['A', 'B', 'C', 'D', 'E']
         color_args = ['r', 'g', 'b', 'c', 'm']
-        axes = _check_plot_works(df.plot.pie, filterwarnings='ignore',
-                                 subplots=True, labels=labels,
-                                 colors=color_args)
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.plot.pie,
+                                     subplots=True, labels=labels,
+                                     colors=color_args)
         self.assertEqual(len(axes), len(df.columns))
 
         for ax in axes:
@@ -3362,9 +3388,12 @@ def test_errorbar_plot(self):
             self._check_has_errorbars(ax, xerr=2, yerr=2)
             ax = _check_plot_works(df.plot, xerr=0.2, yerr=0.2, kind=kind)
             self._check_has_errorbars(ax, xerr=2, yerr=2)
-            axes = _check_plot_works(df.plot, filterwarnings='ignore',
-                                     yerr=df_err, xerr=df_err, subplots=True,
-                                     kind=kind)
+            # _check_plot_works adds an ax so catch warning. see GH #13188
+            with tm.assert_produces_warning(UserWarning):
+                axes = _check_plot_works(df.plot,
+                                         yerr=df_err, xerr=df_err,
+                                         subplots=True,
+                                         kind=kind)
             self._check_has_errorbars(axes, xerr=1, yerr=1)
 
         ax = _check_plot_works((df + 1).plot, yerr=df_err,
@@ -3455,8 +3484,11 @@ def test_errorbar_timeseries(self):
             self._check_has_errorbars(ax, xerr=0, yerr=1)
             ax = _check_plot_works(tdf.plot, yerr=tdf_err, kind=kind)
             self._check_has_errorbars(ax, xerr=0, yerr=2)
-            axes = _check_plot_works(tdf.plot, filterwarnings='ignore',
-                                     kind=kind, yerr=tdf_err, subplots=True)
+            # _check_plot_works adds an ax so catch warning. see GH #13188
+            with tm.assert_produces_warning(UserWarning):
+                axes = _check_plot_works(tdf.plot,
+                                         kind=kind, yerr=tdf_err,
+                                         subplots=True)
             self._check_has_errorbars(axes, xerr=0, yerr=1)
 
     def test_errorbar_asymmetrical(self):
diff --git a/pandas/tests/test_graphics_others.py b/pandas/tests/test_graphics_others.py
--- a/pandas/tests/test_graphics_others.py
+++ b/pandas/tests/test_graphics_others.py
@@ -5,7 +5,6 @@
 import itertools
 import os
 import string
-import warnings
 from distutils.version import LooseVersion
 
 from pandas import Series, DataFrame, MultiIndex
@@ -61,8 +60,11 @@ def test_hist_legacy(self):
         _check_plot_works(self.ts.hist)
         _check_plot_works(self.ts.hist, grid=False)
         _check_plot_works(self.ts.hist, figsize=(8, 10))
-        _check_plot_works(self.ts.hist, by=self.ts.index.month)
-        _check_plot_works(self.ts.hist, by=self.ts.index.month, bins=5)
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(self.ts.hist, by=self.ts.index.month)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(self.ts.hist, by=self.ts.index.month, bins=5)
 
         fig, ax = self.plt.subplots(1, 1)
         _check_plot_works(self.ts.hist, ax=ax)
@@ -96,29 +98,42 @@ def test_hist_layout(self):
     def test_hist_layout_with_by(self):
         df = self.hist_df
 
-        axes = _check_plot_works(df.height.hist, by=df.gender, layout=(2, 1))
+        # _check_plot_works adds an `ax` kwarg to the method call
+        # so we get a warning about an axis being cleared, even
+        # though we don't explicing pass one, see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist, by=df.gender,
+                                     layout=(2, 1))
         self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
 
-        axes = _check_plot_works(df.height.hist, by=df.gender, layout=(3, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist, by=df.gender,
+                                     layout=(3, -1))
         self._check_axes_shape(axes, axes_num=2, layout=(3, 1))
 
-        axes = _check_plot_works(df.height.hist, by=df.category, layout=(4, 1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.height.hist, by=df.category,
+                                     layout=(4, 1))
         self._check_axes_shape(axes, axes_num=4, layout=(4, 1))
 
-        axes = _check_plot_works(
-            df.height.hist, by=df.category, layout=(2, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(
+                df.height.hist, by=df.category, layout=(2, -1))
         self._check_axes_shape(axes, axes_num=4, layout=(2, 2))
 
-        axes = _check_plot_works(
-            df.height.hist, by=df.category, layout=(3, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(
+                df.height.hist, by=df.category, layout=(3, -1))
         self._check_axes_shape(axes, axes_num=4, layout=(3, 2))
 
-        axes = _check_plot_works(
-            df.height.hist, by=df.category, layout=(-1, 4))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(
+                df.height.hist, by=df.category, layout=(-1, 4))
         self._check_axes_shape(axes, axes_num=4, layout=(1, 4))
 
-        axes = _check_plot_works(
-            df.height.hist, by=df.classroom, layout=(2, 2))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(
+                df.height.hist, by=df.classroom, layout=(2, 2))
         self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
 
         axes = df.height.hist(by=df.category, layout=(4, 2), figsize=(12, 7))
@@ -135,7 +150,7 @@ def test_hist_no_overlap(self):
         subplot(122)
         y.hist()
         fig = gcf()
-        axes = fig.get_axes()
+        axes = fig.axes if self.mpl_ge_1_5_0 else fig.get_axes()
         self.assertEqual(len(axes), 2)
 
     @slow
@@ -203,33 +218,43 @@ def test_boxplot_legacy(self):
         _check_plot_works(df.boxplot, return_type='dict')
         _check_plot_works(df.boxplot, column=[
                           'one', 'two'], return_type='dict')
-        _check_plot_works(df.boxplot, column=['one', 'two'], by='indic')
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.boxplot, column=['one', 'two'],
+                              by='indic')
         _check_plot_works(df.boxplot, column='one', by=['indic', 'indic2'])
-        _check_plot_works(df.boxplot, by='indic')
-        _check_plot_works(df.boxplot, by=['indic', 'indic2'])
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.boxplot, by='indic')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.boxplot, by=['indic', 'indic2'])
         _check_plot_works(plotting.boxplot, data=df['one'], return_type='dict')
         _check_plot_works(df.boxplot, notch=1, return_type='dict')
-        _check_plot_works(df.boxplot, by='indic', notch=1)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.boxplot, by='indic', notch=1)
 
         df = DataFrame(np.random.rand(10, 2), columns=['Col1', 'Col2'])
         df['X'] = Series(['A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B'])
         df['Y'] = Series(['A'] * 10)
-        _check_plot_works(df.boxplot, by='X')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.boxplot, by='X')
 
         # When ax is supplied and required number of axes is 1,
         # passed ax should be used:
         fig, ax = self.plt.subplots()
         axes = df.boxplot('Col1', by='X', ax=ax)
-        self.assertIs(ax.get_axes(), axes)
+        ax_axes = ax.axes if self.mpl_ge_1_5_0 else ax.get_axes()
+        self.assertIs(ax_axes, axes)
 
         fig, ax = self.plt.subplots()
         axes = df.groupby('Y').boxplot(ax=ax, return_type='axes')
-        self.assertIs(ax.get_axes(), axes['A'])
+        ax_axes = ax.axes if self.mpl_ge_1_5_0 else ax.get_axes()
+        self.assertIs(ax_axes, axes['A'])
 
         # Multiple columns with an ax argument should use same figure
         fig, ax = self.plt.subplots()
-        axes = df.boxplot(column=['Col1', 'Col2'],
-                          by='X', ax=ax, return_type='axes')
+        with tm.assert_produces_warning(UserWarning):
+            axes = df.boxplot(column=['Col1', 'Col2'],
+                              by='X', ax=ax, return_type='axes')
         self.assertIs(axes['Col1'].get_figure(), fig)
 
         # When by is None, check that all relevant lines are present in the
@@ -304,11 +329,13 @@ def test_boxplot_empty_column(self):
     @slow
     def test_hist_df_legacy(self):
         from matplotlib.patches import Rectangle
-        _check_plot_works(self.hist_df.hist)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(self.hist_df.hist)
 
         # make sure layout is handled
         df = DataFrame(randn(100, 3))
-        axes = _check_plot_works(df.hist, grid=False)
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.hist, grid=False)
         self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
         self.assertFalse(axes[1, 1].get_visible())
 
@@ -317,17 +344,21 @@ def test_hist_df_legacy(self):
 
         # make sure layout is handled
         df = DataFrame(randn(100, 6))
-        axes = _check_plot_works(df.hist, layout=(4, 2))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.hist, layout=(4, 2))
         self._check_axes_shape(axes, axes_num=6, layout=(4, 2))
 
         # make sure sharex, sharey is handled
-        _check_plot_works(df.hist, sharex=True, sharey=True)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.hist, sharex=True, sharey=True)
 
         # handle figsize arg
-        _check_plot_works(df.hist, figsize=(8, 10))
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.hist, figsize=(8, 10))
 
         # check bins argument
-        _check_plot_works(df.hist, bins=5)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(df.hist, bins=5)
 
         # make sure xlabelsize and xrot are handled
         ser = df[0]
@@ -401,22 +432,30 @@ def test_scatter_plot_legacy(self):
         def scat(**kwds):
             return plotting.scatter_matrix(df, **kwds)
 
-        _check_plot_works(scat)
-        _check_plot_works(scat, marker='+')
-        _check_plot_works(scat, vmin=0)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat, marker='+')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat, vmin=0)
         if _ok_for_gaussian_kde('kde'):
-            _check_plot_works(scat, diagonal='kde')
+            with tm.assert_produces_warning(UserWarning):
+                _check_plot_works(scat, diagonal='kde')
         if _ok_for_gaussian_kde('density'):
-            _check_plot_works(scat, diagonal='density')
-        _check_plot_works(scat, diagonal='hist')
-        _check_plot_works(scat, range_padding=.1)
+            with tm.assert_produces_warning(UserWarning):
+                _check_plot_works(scat, diagonal='density')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat, diagonal='hist')
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat, range_padding=.1)
 
         def scat2(x, y, by=None, ax=None, figsize=None):
             return plotting.scatter_plot(df, x, y, by, ax, figsize=None)
 
         _check_plot_works(scat2, x=0, y=1)
         grouper = Series(np.repeat([1, 2, 3, 4, 5], 20), df.index)
-        _check_plot_works(scat2, x=0, y=1, by=grouper)
+        with tm.assert_produces_warning(UserWarning):
+            _check_plot_works(scat2, x=0, y=1, by=grouper)
 
     def test_scatter_matrix_axis(self):
         tm._skip_if_no_scipy()
@@ -607,8 +646,7 @@ class TestDataFrameGroupByPlots(TestPlotBase):
     @slow
     def test_boxplot_legacy(self):
         grouped = self.hist_df.groupby(by='gender')
-        with warnings.catch_warnings():
-            warnings.simplefilter('ignore')
+        with tm.assert_produces_warning(UserWarning):
             axes = _check_plot_works(grouped.boxplot, return_type='axes')
         self._check_axes_shape(list(axes.values()), axes_num=2, layout=(1, 2))
 
@@ -620,7 +658,8 @@ def test_boxplot_legacy(self):
                        index=MultiIndex.from_tuples(tuples))
 
         grouped = df.groupby(level=1)
-        axes = _check_plot_works(grouped.boxplot, return_type='axes')
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(grouped.boxplot, return_type='axes')
         self._check_axes_shape(list(axes.values()), axes_num=10, layout=(4, 3))
 
         axes = _check_plot_works(grouped.boxplot, subplots=False,
@@ -628,7 +667,8 @@ def test_boxplot_legacy(self):
         self._check_axes_shape(axes, axes_num=1, layout=(1, 1))
 
         grouped = df.unstack(level=1).groupby(level=0, axis=1)
-        axes = _check_plot_works(grouped.boxplot, return_type='axes')
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(grouped.boxplot, return_type='axes')
         self._check_axes_shape(list(axes.values()), axes_num=3, layout=(2, 2))
 
         axes = _check_plot_works(grouped.boxplot, subplots=False,
@@ -774,18 +814,22 @@ def test_grouped_box_layout(self):
         self.assertRaises(ValueError, df.boxplot, column=['weight', 'height'],
                           by=df.gender, layout=(-1, -1))
 
-        box = _check_plot_works(df.groupby('gender').boxplot, column='height',
-                                return_type='dict')
+        # _check_plot_works adds an ax so catch warning. see GH #13188
+        with tm.assert_produces_warning(UserWarning):
+            box = _check_plot_works(df.groupby('gender').boxplot,
+                                    column='height', return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=2, layout=(1, 2))
 
-        box = _check_plot_works(df.groupby('category').boxplot,
-                                column='height',
-                                return_type='dict')
+        with tm.assert_produces_warning(UserWarning):
+            box = _check_plot_works(df.groupby('category').boxplot,
+                                    column='height',
+                                    return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=4, layout=(2, 2))
 
         # GH 6769
-        box = _check_plot_works(df.groupby('classroom').boxplot,
-                                column='height', return_type='dict')
+        with tm.assert_produces_warning(UserWarning):
+            box = _check_plot_works(df.groupby('classroom').boxplot,
+                                    column='height', return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(2, 2))
 
         # GH 5897
@@ -803,13 +847,15 @@ def test_grouped_box_layout(self):
             column=['height', 'weight', 'category'], return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=3, layout=(2, 2))
 
-        box = _check_plot_works(df.groupby('category').boxplot,
-                                column='height',
-                                layout=(3, 2), return_type='dict')
+        with tm.assert_produces_warning(UserWarning):
+            box = _check_plot_works(df.groupby('category').boxplot,
+                                    column='height',
+                                    layout=(3, 2), return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=4, layout=(3, 2))
-        box = _check_plot_works(df.groupby('category').boxplot,
-                                column='height',
-                                layout=(3, -1), return_type='dict')
+        with tm.assert_produces_warning(UserWarning):
+            box = _check_plot_works(df.groupby('category').boxplot,
+                                    column='height',
+                                    layout=(3, -1), return_type='dict')
         self._check_axes_shape(self.plt.gcf().axes, axes_num=4, layout=(3, 2))
 
         box = df.boxplot(column=['height', 'weight', 'category'], by='gender',
@@ -848,8 +894,7 @@ def test_grouped_box_multiple_axes(self):
                                    axes_num=4, layout=(2, 2))
 
         fig, axes = self.plt.subplots(2, 3)
-        with warnings.catch_warnings():
-            warnings.simplefilter('ignore')
+        with tm.assert_produces_warning(UserWarning):
             returned = df.boxplot(column=['height', 'weight', 'category'],
                                   by='gender', return_type='axes', ax=axes[0])
         returned = np.array(list(returned.values()))
@@ -858,8 +903,7 @@ def test_grouped_box_multiple_axes(self):
         self.assertIs(returned[0].figure, fig)
 
         # draw on second row
-        with warnings.catch_warnings():
-            warnings.simplefilter('ignore')
+        with tm.assert_produces_warning(UserWarning):
             returned = df.groupby('classroom').boxplot(
                 column=['height', 'weight', 'category'],
                 return_type='axes', ax=axes[1])
@@ -871,7 +915,8 @@ def test_grouped_box_multiple_axes(self):
         with tm.assertRaises(ValueError):
             fig, axes = self.plt.subplots(2, 3)
             # pass different number of axes from required
-            axes = df.groupby('classroom').boxplot(ax=axes)
+            with tm.assert_produces_warning(UserWarning):
+                axes = df.groupby('classroom').boxplot(ax=axes)
 
     @slow
     def test_grouped_hist_layout(self):
@@ -883,12 +928,14 @@ def test_grouped_hist_layout(self):
         self.assertRaises(ValueError, df.hist, column='height', by=df.category,
                           layout=(-1, -1))
 
-        axes = _check_plot_works(df.hist, column='height', by=df.gender,
-                                 layout=(2, 1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.hist, column='height', by=df.gender,
+                                     layout=(2, 1))
         self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
 
-        axes = _check_plot_works(df.hist, column='height', by=df.gender,
-                                 layout=(2, -1))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.hist, column='height', by=df.gender,
+                                     layout=(2, -1))
         self._check_axes_shape(axes, axes_num=2, layout=(2, 1))
 
         axes = df.hist(column='height', by=df.category, layout=(4, 1))
@@ -904,12 +951,14 @@ def test_grouped_hist_layout(self):
         tm.close()
 
         # GH 6769
-        axes = _check_plot_works(
-            df.hist, column='height', by='classroom', layout=(2, 2))
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(
+                df.hist, column='height', by='classroom', layout=(2, 2))
         self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
 
         # without column
-        axes = _check_plot_works(df.hist, by='classroom')
+        with tm.assert_produces_warning(UserWarning):
+            axes = _check_plot_works(df.hist, by='classroom')
         self._check_axes_shape(axes, axes_num=3, layout=(2, 2))
 
         axes = df.hist(by='gender', layout=(3, 5))