From 46f25e40c5be69a5a3007c3d60786d6e36f6a899 Mon Sep 17 00:00:00 2001 From: sinhrks Date: Sat, 17 Jan 2015 11:09:24 +0900 Subject: [PATCH] BUG: Subplotting boxplot shows unnecessary warnings --- doc/source/whatsnew/v0.16.0.txt | 2 +- pandas/tests/test_graphics.py | 17 ++++++++--------- pandas/tools/plotting.py | 11 ++++++++++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/source/whatsnew/v0.16.0.txt b/doc/source/whatsnew/v0.16.0.txt index 2db455272363b..53ed040860269 100644 --- a/doc/source/whatsnew/v0.16.0.txt +++ b/doc/source/whatsnew/v0.16.0.txt @@ -172,7 +172,7 @@ Bug Fixes - +- Bug in boxplot, scatter and hexbin plot may show an unnecessary warning (:issue:`8877`) diff --git a/pandas/tests/test_graphics.py b/pandas/tests/test_graphics.py index 109d9e7c00c6b..4195baf4874f1 100644 --- a/pandas/tests/test_graphics.py +++ b/pandas/tests/test_graphics.py @@ -1900,15 +1900,14 @@ def test_boxplot(self): # different warning on py3 if not PY3: - with tm.assert_produces_warning(UserWarning): - axes = _check_plot_works(df.plot, kind='box', - subplots=True, logy=True) - - self._check_axes_shape(axes, axes_num=3, layout=(1, 3)) - self._check_ax_scales(axes, yaxis='log') - for ax, label in zip(axes, labels): - self._check_text_labels(ax.get_xticklabels(), [label]) - self.assertEqual(len(ax.lines), self.bp_n_objects) + axes = _check_plot_works(df.plot, kind='box', + subplots=True, logy=True) + + self._check_axes_shape(axes, axes_num=3, layout=(1, 3)) + self._check_ax_scales(axes, yaxis='log') + for ax, label in zip(axes, labels): + self._check_text_labels(ax.get_xticklabels(), [label]) + self.assertEqual(len(ax.lines), self.bp_n_objects) axes = series.plot(kind='box', rot=40) self._check_ticks_props(axes, xrot=40, yrot=0) diff --git a/pandas/tools/plotting.py b/pandas/tools/plotting.py index 2d7976d567108..9919415b06546 100644 --- a/pandas/tools/plotting.py +++ b/pandas/tools/plotting.py @@ -1451,7 +1451,10 @@ def _make_plot(self): kws['label'] = c if c_is_column else '' self.fig.colorbar(img, **kws) - self._add_legend_handle(scatter, label) + if label is not None: + self._add_legend_handle(scatter, label) + else: + self.legend = False errors_x = self._get_errorbars(label=x, index=0, yerr=False) errors_y = self._get_errorbars(label=y, index=0, xerr=False) @@ -1512,6 +1515,9 @@ def _make_plot(self): img = ax.collections[0] self.fig.colorbar(img, ax=ax) + def _make_legend(self): + pass + def _post_plot_logic(self): ax = self.axes[0] x, y = self.x, self.y @@ -2228,6 +2234,9 @@ def _set_ticklabels(self, ax, labels): else: ax.set_yticklabels(labels) + def _make_legend(self): + pass + def _post_plot_logic(self): pass