Register a new color sequence. The color sequence registry stores a copy of the given *color_list*, so that future changes to the original list do not affect the registered color sequence. Think of this as the registry taking a snapshot of *color_list* at re
(self, name, color_list)
| 156 | ', '.join(f"'{name}'" for name in self)) |
| 157 | |
| 158 | def register(self, name, color_list): |
| 159 | """ |
| 160 | Register a new color sequence. |
| 161 | |
| 162 | The color sequence registry stores a copy of the given *color_list*, so |
| 163 | that future changes to the original list do not affect the registered |
| 164 | color sequence. Think of this as the registry taking a snapshot |
| 165 | of *color_list* at registration. |
| 166 | |
| 167 | Parameters |
| 168 | ---------- |
| 169 | name : str |
| 170 | The name for the color sequence. |
| 171 | |
| 172 | color_list : list of :mpltype:`color` |
| 173 | An iterable returning valid Matplotlib colors when iterating over. |
| 174 | Note however that the returned color sequence will always be a |
| 175 | list regardless of the input type. |
| 176 | |
| 177 | """ |
| 178 | if name in self._BUILTIN_COLOR_SEQUENCES: |
| 179 | raise ValueError(f"{name!r} is a reserved name for a builtin " |
| 180 | "color sequence") |
| 181 | |
| 182 | color_list = list(color_list) # force copy and coerce type to list |
| 183 | for color in color_list: |
| 184 | try: |
| 185 | to_rgba(color) |
| 186 | except ValueError: |
| 187 | raise ValueError( |
| 188 | f"{color!r} is not a valid color specification") |
| 189 | |
| 190 | self._color_sequences[name] = color_list |
| 191 | |
| 192 | def unregister(self, name): |
| 193 | """ |