From 421def8acb18f9cf7cbfd3eb75af6590be7f8d93 Mon Sep 17 00:00:00 2001 From: wendycwong Date: Wed, 30 Oct 2024 08:25:00 -0700 Subject: [PATCH] [GH-16333] fix pyplot warning (#16381) (#16441) Co-authored-by: krasinski <8573352+krasinski@users.noreply.github.com> --- h2o-py/h2o/plot/_matplotlib.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/h2o-py/h2o/plot/_matplotlib.py b/h2o-py/h2o/plot/_matplotlib.py index d7e97caf541c..ae615155f3bd 100644 --- a/h2o-py/h2o/plot/_matplotlib.py +++ b/h2o-py/h2o/plot/_matplotlib.py @@ -5,7 +5,10 @@ def get_matplotlib_pyplot(server, raise_if_not_available=False): # noinspection PyUnresolvedReferences import matplotlib if server: - matplotlib.use("Agg") + if matplotlib.get_backend() != "Agg": + import matplotlib.pyplot as plt + plt.close('all') + matplotlib.use("Agg") try: # noinspection PyUnresolvedReferences import matplotlib.pyplot as plt