Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.16.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Bug Fixes


- Bug in boxplot, scatter and hexbin plot may show an unnecessary warning (:issue:`8877`)
- Bug in subplot with ``layout`` kw may show unnecessary warning (:issue:`9464`)



Expand Down
17 changes: 17 additions & 0 deletions pandas/tests/test_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import itertools
import os
import string
import warnings
from distutils.version import LooseVersion

from datetime import datetime, date
Expand Down Expand Up @@ -1245,6 +1246,7 @@ def test_subplots_timeseries(self):
self._check_visible(ax.get_yticklabels())
self._check_ticks_props(ax, xlabelsize=7, xrot=45, ylabelsize=7)

@slow
def test_subplots_layout(self):
# GH 6667
df = DataFrame(np.random.rand(10, 3),
Expand Down Expand Up @@ -1290,6 +1292,21 @@ def test_subplots_layout(self):
self._check_axes_shape(axes, axes_num=1, layout=(3, 3))
self.assertEqual(axes.shape, (3, 3))

@slow
def test_subplots_warnings(self):
# GH 9464
warnings.simplefilter('error')
try:
df = DataFrame(np.random.randn(100, 4))
df.plot(subplots=True, layout=(3, 2))

df = DataFrame(np.random.randn(100, 4),
index=date_range('1/1/2000', periods=100))
df.plot(subplots=True, layout=(3, 2))
except Warning as w:
self.fail(w)
warnings.simplefilter('default')

@slow
def test_subplots_multiple_axes(self):
# GH 5353, 6970, GH 7069
Expand Down
3 changes: 2 additions & 1 deletion pandas/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,8 @@ def _make_legend(self):

elif self.subplots and self.legend:
for ax in self.axes:
ax.legend(loc='best')
if ax.get_visible():
ax.legend(loc='best')

def _get_ax_legend(self, ax):
leg = ax.get_legend()
Expand Down