From bc77ac54c42a8d15b5f0e00867ed938349f8e565 Mon Sep 17 00:00:00 2001 From: Kazuki Oikawa Date: Sat, 21 Sep 2024 01:47:03 +0900 Subject: [PATCH] Fixed matplotlib is required --- specparam/plts/settings.py | 6 ++++-- specparam/plts/style.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/specparam/plts/settings.py b/specparam/plts/settings.py index 263a5bee..b231e6da 100644 --- a/specparam/plts/settings.py +++ b/specparam/plts/settings.py @@ -2,13 +2,15 @@ from collections import OrderedDict -import matplotlib.pyplot as plt +from specparam.core.modutils import safe_import + +plt = safe_import('.pyplot', 'matplotlib') ################################################################################################### ################################################################################################### # Define list of default plot colors -DEFAULT_COLORS = plt.rcParams['axes.prop_cycle'].by_key()['color'] +DEFAULT_COLORS = plt.rcParams['axes.prop_cycle'].by_key()['color'] if plt else None # Define default figure sizes PLT_FIGSIZES = {'spectral' : (8.5, 6.5), diff --git a/specparam/plts/style.py b/specparam/plts/style.py index 05bff602..8b5a71a5 100644 --- a/specparam/plts/style.py +++ b/specparam/plts/style.py @@ -3,12 +3,13 @@ from itertools import cycle from functools import wraps -import matplotlib.pyplot as plt - +from specparam.core.modutils import safe_import from specparam.plts.settings import (AXIS_STYLE_ARGS, LINE_STYLE_ARGS, COLLECTION_STYLE_ARGS, CUSTOM_STYLE_ARGS, STYLE_ARGS, TICK_LABELSIZE, TITLE_FONTSIZE, LABEL_SIZE, LEGEND_SIZE, LEGEND_LOC) +plt = safe_import('.pyplot', 'matplotlib') + ################################################################################################### ###################################################################################################