From b021091f8b1ee3bd1edbb52a81252884c43e5ca6 Mon Sep 17 00:00:00 2001 From: Bob Yantosca Date: Fri, 20 Oct 2023 11:02:41 -0400 Subject: [PATCH] Hotfix: Comment out X11 backend commands in the plotting example code Newer versions of matplotlib require you to specify an X11 backend library for matplotlib.pyplot.show() to work. This requires us to add an additional library to the gcpy_env environment. For now, comment out the lines that invoke the X11 backend so as to allow cloud benchmark simulations to work. We will restore these once the cloud container has been updated. gcpy/examples/plotting/plot_comparisons.py gcpy/examples/plotting/plot_single_panel.py - Comment out the line to use the TkAgg backend. This needs the "tk" package to be installed in the GCPy environment. gcpy/docs/environment_files/environment.yml - Add "tk" to the list of packages to install Signed-off-by: Bob Yantosca --- docs/environment_files/environment.yml | 1 + gcpy/examples/plotting/plot_comparisons.py | 2 +- gcpy/examples/plotting/plot_single_panel.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/environment_files/environment.yml b/docs/environment_files/environment.yml index a4461795..9c399688 100644 --- a/docs/environment_files/environment.yml +++ b/docs/environment_files/environment.yml @@ -35,6 +35,7 @@ dependencies: - scipy # Scientific python package - sparselt>=0.1.3 # Regridding earth system model data - tabulate # Pretty-printing for column data + - tk # Tcl/Tk interface - xarray # Read data from netCDF etc files # # NOTE: These packages need to be pegged at specific versions diff --git a/gcpy/examples/plotting/plot_comparisons.py b/gcpy/examples/plotting/plot_comparisons.py index 1ee318db..649b04b7 100755 --- a/gcpy/examples/plotting/plot_comparisons.py +++ b/gcpy/examples/plotting/plot_comparisons.py @@ -15,7 +15,7 @@ import argparse import xarray as xr from matplotlib import use as mpl_use -mpl_use("TkAgg") # X11 backend for plt.show() +#mpl_use("TkAgg") # X11 backend for plt.show() import matplotlib.pyplot as plt from gcpy import plot from gcpy.constants import skip_these_vars diff --git a/gcpy/examples/plotting/plot_single_panel.py b/gcpy/examples/plotting/plot_single_panel.py index a66af652..1980ef12 100755 --- a/gcpy/examples/plotting/plot_single_panel.py +++ b/gcpy/examples/plotting/plot_single_panel.py @@ -16,7 +16,7 @@ import argparse import xarray as xr from matplotlib import use as mpl_use -mpl_use("TkAgg") # X11 backend for plt.show() +#mpl_use("TkAgg") # X11 backend for plt.show() import matplotlib.pyplot as plt from gcpy import plot from gcpy.util import rename_and_flip_gchp_rst_vars