Skip to content

Commit

Permalink
Use matplotlib's style sheet as default color scheme.
Browse files Browse the repository at this point in the history
'seaborn-v0_8-colorblind' is used as default.
But off-black is inserted as the first available color, for observation.
  • Loading branch information
HansKimDWR committed Apr 24, 2024
1 parent 2bfc5ec commit 195fa7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
13 changes: 7 additions & 6 deletions schimpy/batch_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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']:
Expand All @@ -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']:
Expand All @@ -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)
Expand All @@ -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':
Expand Down
4 changes: 4 additions & 0 deletions schimpy/plot_default_formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 195fa7c

Please sign in to comment.