Skip to content

Commit 98ba07a

Browse files
Backport PR #59168 on branch 2.2.x (TST: Address UserWarning in matplotlib test) (#59175)
Backport PR #59168: TST: Address UserWarning in matplotlib test Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 243457d commit 98ba07a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pandas/plotting/_matplotlib/core.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,13 @@ def _make_legend(self) -> None:
893893
elif self.subplots and self.legend:
894894
for ax in self.axes:
895895
if ax.get_visible():
896-
ax.legend(loc="best")
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)