skais_mapper.utils.colors
Color module for more beautiful plots.
Classes:
Name | Description |
---|---|
SkaisColorMaps |
An assortment of linearly interpolated colormaps based on 4+ colors each. |
SkaisColors |
An assortment of colors and palettes. |
Functions:
Name | Description |
---|---|
color_variant |
Takes a color in hex code and produces a lighter or darker shift variant. |
ReNormColormapAdaptor
ReNormColormapAdaptor(
base,
cmap_norm: Normalize,
orig_norm: Normalize | None = None,
)
Bases: Colormap
Adaptor for re-normalizing color mappable.
Methods:
Name | Description |
---|---|
__call__ |
Re-normalise the values before applying the colormap. |
reversed |
Abstract dummy method. |
Source code in skais_mapper/utils/colors.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
|
__call__
__call__(X, **kwargs)
Re-normalise the values before applying the colormap.
Source code in skais_mapper/utils/colors.py
55 56 57 |
|
reversed
reversed(*args, **kwargs)
Abstract dummy method.
Source code in skais_mapper/utils/colors.py
66 67 |
|
SkaisColorMaps
An assortment of linearly interpolated colormaps based on 4+ colors each.
Methods:
Name | Description |
---|---|
gen |
Generate colormaps. |
palette |
Return a palette of a colormap with N linearly interpolated color points. |
plot_gradients |
Plot all color-map gradients. |
random |
Choose a random color map. |
register_all |
Register colormaps with matplotlib. |
reverse |
Reverse the specified colormap. |
gen
classmethod
gen()
Generate colormaps.
Returns:
Type | Description |
---|---|
mpl.colors.LinearSegmentedColormap object
|
colormap generated from custom list |
Source code in skais_mapper/utils/colors.py
271 272 273 274 275 276 277 278 |
|
palette
classmethod
palette(cmap_name: str, N: int)
Return a palette of a colormap with N linearly interpolated color points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap_name
|
str
|
name of the colormap |
required |
N
|
int
|
number of colors in the palette |
required |
Source code in skais_mapper/utils/colors.py
318 319 320 321 322 323 324 325 326 327 328 329 |
|
plot_gradients
classmethod
plot_gradients(savefig: bool = False)
Plot all color-map gradients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
savefig
|
bool
|
save figure as palettes.png |
False
|
Source code in skais_mapper/utils/colors.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
|
random
classmethod
random() -> LinearSegmentedColormap
Choose a random color map.
Returns:
Name | Type | Description |
---|---|---|
cmap |
LinearSegmentedColormap
|
random colormap from custom list |
Source code in skais_mapper/utils/colors.py
262 263 264 265 266 267 268 269 |
|
register_all
staticmethod
register_all(verbose: bool = False)
Register colormaps with matplotlib.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbose
|
bool
|
If True, print information to command line |
False
|
Source code in skais_mapper/utils/colors.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
|
reverse
classmethod
reverse(
cmap: Colormap,
set_bad: str = None,
set_under: str = None,
set_over: str = None,
) -> LinearSegmentedColormap
Reverse the specified colormap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap
|
mpl.colors.LinearSegmentedColormap object
|
colormap to be reversed |
required |
set_bad
|
str
|
set colormaps bad values to a different color |
None
|
set_under
|
str
|
set colormaps under values to a different color |
None
|
set_over
|
str
|
set colormaps over values to a different color |
None
|
Returns:
Type | Description |
---|---|
mpl.colors.LinearSegmentedColormap object
|
reversed colormap |
Source code in skais_mapper/utils/colors.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
SkaisColors
An assortment of colors and palettes.
Methods:
Name | Description |
---|---|
cmap_from_color |
Create a colormap from a single color. |
cmap_from_color
classmethod
cmap_from_color(
color_str: str, secondary_color: str | None = None
) -> LinearSegmentedColormap
Create a colormap from a single color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
color_str
|
str
|
color string of the class color |
required |
secondary_color
|
str | None
|
color into which the color changes in the colormap |
None
|
Returns:
Type | Description |
---|---|
mpl.colors.LinearSegmentedColormap object
|
reversed colormap |
Source code in skais_mapper/utils/colors.py
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
color_variant
color_variant(hex_color: str, shift: int = 10) -> str
Takes a color in hex code and produces a lighter or darker shift variant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hex_color
|
str
|
formatted as '#' + rgb hex string of length 6 |
required |
shift
|
int
|
decimal shift of the rgb hex string |
10
|
Returns:
Name | Type | Description |
---|---|---|
variant |
str
|
formatted as '#' + rgb hex string of length 6 |
Source code in skais_mapper/utils/colors.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|