Skip to content

Commit 45741da

Browse files
committed
Filter the warning instead
1 parent 4fe2ab2 commit 45741da

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pandas/plotting/_matplotlib/core.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,14 @@ def _make_legend(self) -> None:
892892

893893
elif self.subplots and self.legend:
894894
for ax in self.axes:
895-
if ax.get_visible() and ax.get_label():
896-
ax.legend(loc="best")
895+
if ax.get_visible():
896+
with warnings.catch_warnings():
897+
warnings.filterwarnings(
898+
"ignore",
899+
"No artists with labels found to put in legend.",
900+
UserWarning,
901+
)
902+
ax.legend(loc="best")
897903

898904
@final
899905
@staticmethod

0 commit comments

Comments
 (0)