From 3b2afb56ca299d46c1d27576767c3193fb4e1940 Mon Sep 17 00:00:00 2001 From: krasinski <8573352+krasinski@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:49:40 +0200 Subject: [PATCH] [GH-16333] fix pyplot warning (#16381) --- 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