From a6516c9c6fc5a2de24cd9cfd1a9f57eadef0c168 Mon Sep 17 00:00:00 2001 From: alphasentaurii Date: Tue, 2 Apr 2024 11:11:56 -0400 Subject: [PATCH] mpl style config setting fix --- CHANGES.rst | 6 +++++- spacekit/analyzer/compute.py | 9 +++++++-- spacekit/analyzer/explore.py | 9 +++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 7ef08be..6ce8786 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -4,7 +4,11 @@ bugfixes -------- -- move HstSvmRadio import inside class method to avoid importing astroquery unnecessarily; temporarily pin tf max version to 2.15 to ensure compatibility with models saved in 2.13 or older [#49] +- move HstSvmRadio import inside class method to avoid importing astroquery unnecessarily [#49] + +- temporarily pin tf max version to 2.15 to ensure compatibility with models saved in 2.13 or older + +- matplotlib style setting looks for "seaborn-v0_8-bright" if "seaborn-bright" unavailable, fallback uses default style installation / automation diff --git a/spacekit/analyzer/compute.py b/spacekit/analyzer/compute.py index a5e5447..6dd7e1c 100644 --- a/spacekit/analyzer/compute.py +++ b/spacekit/analyzer/compute.py @@ -20,10 +20,15 @@ import plotly.graph_objects as go import matplotlib as mpl import matplotlib.pyplot as plt - - plt.style.use("seaborn-bright") font_dict = {"family": "monospace", "size": 16} # Titillium Web mpl.rc("font", **font_dict) + styles = ["seaborn-bright", "seaborn-v0_8-bright"] + valid_styles = [s for s in styles if s in plt.style.available] + if len(valid_styles) > 0: + try: + plt.style.use(valid_styles[0]) + except OSError: + pass except ImportError: go = None mpl = None diff --git a/spacekit/analyzer/explore.py b/spacekit/analyzer/explore.py index 4a13505..4773865 100644 --- a/spacekit/analyzer/explore.py +++ b/spacekit/analyzer/explore.py @@ -15,10 +15,15 @@ try: import matplotlib as mpl import matplotlib.pyplot as plt - - plt.style.use("seaborn-bright") font_dict = {"family": "monospace", "size": 16} mpl.rc("font", **font_dict) + styles = ["seaborn-bright", "seaborn-v0_8-bright"] + valid_styles = [s for s in styles if s in plt.style.available] + if len(valid_styles) > 0: + try: + plt.style.use(valid_styles[0]) + except OSError: + pass except ImportError: mpl = None plt = None