MCPcopy Create free account
hub / github.com/RolnickLab/climart / RollingCmaps

Class RollingCmaps

climart/utils/plotting.py:73–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

71
72
73class RollingCmaps:
74 def __init__(self,
75 unique_keys: list,
76 pos_cmaps: list = None,
77 max_key_occurence: int = 5):
78 if pos_cmaps is None:
79 pos_cmaps = ['Greens', 'Oranges', 'Blues', 'Greys', 'Purples']
80 pos_cmaps = [plt.get_cmap(cmap) for cmap in pos_cmaps]
81 self.cmaps = {key: pos_cmaps[i] for i, key in enumerate(unique_keys)}
82 self.pos_per_cmap = {key: 0.75 for key in unique_keys} # lower makes lines too white
83 self.max_key_occurence = max_key_occurence
84
85 def __getitem__(self, key):
86 color = self.cmaps[key](self.pos_per_cmap[key] / self.max_key_occurence) # [self.pos_per_cmap[key]]
87 self.pos_per_cmap[key] += 1
88 return color
89
90
91class RollingLineFormats:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected