diff --git a/src/esnb/core/CaseGroup2.py b/src/esnb/core/CaseGroup2.py
index f4ef2ac..4e0fc0b 100644
--- a/src/esnb/core/CaseGroup2.py
+++ b/src/esnb/core/CaseGroup2.py
@@ -216,7 +216,7 @@ def filter_catalog(catalog, variable):
class CaseGroup2:
"""
- CaseGroup2(source, name=None, description=None, concat_dim=None, date_range=None, **kwargs)
+ CaseGroup2(source, name=None, description=None, concat_dim=None, date_range=None, plot_color=None, **kwargs)
A group of case objects with shared metadata and catalog management.
@@ -235,6 +235,8 @@ class CaseGroup2:
Description of the case group.
date_range : tuple or list
The date range used to filter cases.
+ plot_color : str
+ Color associated with the group that is used for plotting.
concat_dim : str
The dimension along which to concatenate cases.
is_resolved : bool
@@ -254,6 +256,7 @@ def __init__(
self,
source,
concat_dim=None,
+ plot_color=None,
name=None,
date_range=None,
description=None,
@@ -296,6 +299,7 @@ def __init__(
self.name = name
self.description = description
self.date_range = date_range
+ self.plot_color = plot_color
self.concat_dim = concat_dim
self.is_resolved = False
self.is_loaded = False
@@ -512,6 +516,8 @@ def color_logical(var):
)
result += f"
| is_resolved | {color_logical(self.is_resolved)} |
"
result += f"| is_loaded | {color_logical(self.is_loaded)} |
"
+ _color = "black" if self.plot_color is None else self.plot_color
+ result += f"| plot_color | {self.plot_color} |
"
result += f"| cases | {self.cases} |
"
if hasattr(self, "datasets"):
diff --git a/src/esnb/core/NotebookDiagnostic.py b/src/esnb/core/NotebookDiagnostic.py
index 6d60770..fb1ff26 100644
--- a/src/esnb/core/NotebookDiagnostic.py
+++ b/src/esnb/core/NotebookDiagnostic.py
@@ -472,6 +472,9 @@ def resolve(self, groups=None):
groups = [] if groups is None else groups
groups = [groups] if not isinstance(groups, list) else groups
+
+ groups = assign_plot_colors(groups)
+
self.groups = groups
if hasattr(self.groups[0], "resolve_datasets"):
# warnings.warn("Legacy CaseGroup object found. Make sure you are using the latest version of ESNB.", DeprecationWarning, stacklevel=2)
@@ -571,6 +574,26 @@ def _repr_html_(self):
return result
+def assign_plot_colors(groups):
+ default_colors = [
+ "royalblue",
+ "darkorange",
+ "forestgreen",
+ "firebrick",
+ "slateblue",
+ "saddlebrown",
+ "deeppink",
+ "dimgray",
+ "olive",
+ "darkcyan",
+ ]
+ for group in groups:
+ if group.plot_color is None:
+ group.plot_color = default_colors[0]
+ default_colors.pop(0)
+ return groups
+
+
def write_cached_datasets(
diag, workdir=None, output_format="zarr", overwrite=False, chunks=None
):