Skip to content

Commit 46f25e4

Browse files
committed
BUG: Subplotting boxplot shows unnecessary warnings
1 parent c567701 commit 46f25e4

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

doc/source/whatsnew/v0.16.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Bug Fixes
172172

173173

174174

175-
175+
- Bug in boxplot, scatter and hexbin plot may show an unnecessary warning (:issue:`8877`)
176176

177177

178178

pandas/tests/test_graphics.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -1900,15 +1900,14 @@ def test_boxplot(self):
19001900

19011901
# different warning on py3
19021902
if not PY3:
1903-
with tm.assert_produces_warning(UserWarning):
1904-
axes = _check_plot_works(df.plot, kind='box',
1905-
subplots=True, logy=True)
1906-
1907-
self._check_axes_shape(axes, axes_num=3, layout=(1, 3))
1908-
self._check_ax_scales(axes, yaxis='log')
1909-
for ax, label in zip(axes, labels):
1910-
self._check_text_labels(ax.get_xticklabels(), [label])
1911-
self.assertEqual(len(ax.lines), self.bp_n_objects)
1903+
axes = _check_plot_works(df.plot, kind='box',
1904+
subplots=True, logy=True)
1905+
1906+
self._check_axes_shape(axes, axes_num=3, layout=(1, 3))
1907+
self._check_ax_scales(axes, yaxis='log')
1908+
for ax, label in zip(axes, labels):
1909+
self._check_text_labels(ax.get_xticklabels(), [label])
1910+
self.assertEqual(len(ax.lines), self.bp_n_objects)
19121911

19131912
axes = series.plot(kind='box', rot=40)
19141913
self._check_ticks_props(axes, xrot=40, yrot=0)

pandas/tools/plotting.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,10 @@ def _make_plot(self):
14511451
kws['label'] = c if c_is_column else ''
14521452
self.fig.colorbar(img, **kws)
14531453

1454-
self._add_legend_handle(scatter, label)
1454+
if label is not None:
1455+
self._add_legend_handle(scatter, label)
1456+
else:
1457+
self.legend = False
14551458

14561459
errors_x = self._get_errorbars(label=x, index=0, yerr=False)
14571460
errors_y = self._get_errorbars(label=y, index=0, xerr=False)
@@ -1512,6 +1515,9 @@ def _make_plot(self):
15121515
img = ax.collections[0]
15131516
self.fig.colorbar(img, ax=ax)
15141517

1518+
def _make_legend(self):
1519+
pass
1520+
15151521
def _post_plot_logic(self):
15161522
ax = self.axes[0]
15171523
x, y = self.x, self.y
@@ -2228,6 +2234,9 @@ def _set_ticklabels(self, ax, labels):
22282234
else:
22292235
ax.set_yticklabels(labels)
22302236

2237+
def _make_legend(self):
2238+
pass
2239+
22312240
def _post_plot_logic(self):
22322241
pass
22332242

0 commit comments

Comments
 (0)