From 195fa7c8bed4b19c1c8c14fce551f63f70093d64 Mon Sep 17 00:00:00 2001 From: "Han Sang (Hans) Kim" Date: Wed, 24 Apr 2024 16:05:43 -0700 Subject: [PATCH] Use matplotlib's style sheet as default color scheme. 'seaborn-v0_8-colorblind' is used as default. But off-black is inserted as the first available color, for observation. --- schimpy/batch_metrics.py | 13 +++++++------ schimpy/plot_default_formats.py | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/schimpy/batch_metrics.py b/schimpy/batch_metrics.py index b5f1fe9..2778af9 100644 --- a/schimpy/batch_metrics.py +++ b/schimpy/batch_metrics.py @@ -23,7 +23,7 @@ safe_window, check_if_all_tss_are_bad, fill_gaps from dms_datastore.read_ts import * -from schimpy.plot_default_formats import dwr_accessiable1_style_cycler +from schimpy.plot_default_formats import dwr_accessiable1_style_cycler,seaborn_style_cycler from cycler import cycler matplotlib.use('Agg') # To prevent an unwanted failure on Linux @@ -553,9 +553,10 @@ def plot(self): labels_to_plot[0] += " - {:g}".format(-adj_obs) if ("palette" in params.keys()): - if params['palette'] == 'dwr_accessible1': + if params['palette'] == 'default': + style_palette=seaborn_style_cycler + elif params['palette'] == 'dwr_accessible1': style_palette=dwr_accessiable1_style_cycler - elif params['palette'] == 'custom': if ('custom_palette' in params.keys()): if 'linecolor' in params['custom_palette']: @@ -564,7 +565,7 @@ def plot(self): raise ValueError("Specify correct number of linecolors!") linecolor = linecolor[:len(labels)] else: - linecolor = dwr_accessiable1_style_cycler.by_key()['color'][:len(labels)] + linecolor = seaborn_style_cycler.by_key()['color'][:len(labels)] print("'linecolor' not specified in 'custom_palette'. Default used") if 'linestyle' in params['custom_palette']: @@ -582,7 +583,7 @@ def plot(self): raise ValueError("Specify correct number of linewidths!") linewidth = linewidth[:len(labels)] else: - linewidth = dwr_accessiable1_style_cycler.by_key()['linewidth'][:len(labels)] + linewidth = seaborn_style_cycler.by_key()['linewidth'][:len(labels)] print("'linewidth' not specified in 'custom_palette'. Default used") style_palette = cycler(color=linecolor, linestyle=linestyle, linewidth=linewidth) @@ -594,7 +595,7 @@ def plot(self): raise ValueError("palette missing!") else: - style_palette=dwr_accessiable1_style_cycler + style_palette=seaborn_style_cycler self.logger.info("No style palette is given, default used.") if plot_format == 'simple': diff --git a/schimpy/plot_default_formats.py b/schimpy/plot_default_formats.py index c6acb81..9831517 100644 --- a/schimpy/plot_default_formats.py +++ b/schimpy/plot_default_formats.py @@ -24,6 +24,10 @@ dwr_accessiable1_style_cycler=(cycler(linestyle=['-','--'])*cycler(color=["#323232","#D55E00","#0173B2"]) *cycler(linewidth=[1.5])) +# Use seaborn-v0_8-colorblind, but insert off-black as the first color. +seaborn_style_cycler=(cycler(linestyle=['-']) + *cycler(color=["#0F0F0F"] + mpl.style.library['seaborn-v0_8-colorblind']["axes.prop_cycle"].by_key()["color"]) + *cycler(linewidth=[1.5])) line_thickness = 1. # Metrics format dictionary