| 89 | |
| 90 | |
| 91 | class RollingLineFormats: |
| 92 | def __init__(self, |
| 93 | unique_keys: list, |
| 94 | pos_markers: list = None, |
| 95 | cmap = None, |
| 96 | linewidth: float = 4 |
| 97 | ): |
| 98 | print(unique_keys) |
| 99 | if pos_markers is None: |
| 100 | pos_markers = ['-', '--', ':', '-', '-.'] |
| 101 | if cmap is None: |
| 102 | cmap = plt.get_cmap('viridis') |
| 103 | cs = ['#1f77b4', '#ff7f0e', '#2ca02c', '#9467bd', '#8c564b', |
| 104 | '#e377c2', '#7f7f7f', '#d62728', '#bcbd22', '#17becf'] |
| 105 | # cs = plt.rcParams['axes.prop_cycle'].by_key()['color'] |
| 106 | |
| 107 | self.pos_markers = pos_markers |
| 108 | # self.cmaps = {key: cmap(i/len(unique_keys)) for i, key in enumerate(unique_keys)} |
| 109 | self.cmaps = {key: cs[i] for i, key in enumerate(unique_keys)} |
| 110 | self.pos_per_key = {key: 0 for key in unique_keys} # lower makes lines too white |
| 111 | self.lws = {key: linewidth for key in unique_keys} |
| 112 | |
| 113 | def __getitem__(self, key): |
| 114 | cur_i = self.pos_per_key[key] |
| 115 | lw = self.lws[key] |
| 116 | line_format = self.pos_markers[cur_i] # [self.pos_per_cmap[key]] |
| 117 | self.pos_per_key[key] += 1 |
| 118 | self.lws[key] = max(1, lw - 1) |
| 119 | return line_format, dict(c=self.cmaps[key], linewidth=lw) |
| 120 | |
| 121 | |
| 122 | def plot_groups(xaxis_key, metric='Test/MAE', ax=None, show: bool = True, **kwargs): |
nothing calls this directly
no outgoing calls
no test coverage detected