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