Utils¶
cmap_to_array(cmap)
¶
Convert a colormap to an array of colors as RGB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap
|
Colormap | Sequence
|
A colormap. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
An array of colors. |
Source code in tastymap/utils.py
get_cmap(cmap)
¶
Get a colormap by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap
|
str
|
The name of the colormap. |
required |
Returns:
Type | Description |
---|---|
Colormap
|
A colormap. |
Source code in tastymap/utils.py
get_registered_cmaps()
¶
Get a mapping of registered colormaps.
Returns:
Type | Description |
---|---|
dict[str, str]
|
A mapping of registered colormaps. |
replace_match(pattern, string, key)
¶
Find a pattern in a string and remove it.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern
|
str
|
The pattern to find. |
required |
string
|
str
|
The string to search. |
required |
key
|
str
|
The name of the pattern. |
required |
Returns:
Type | Description |
---|---|
tuple[str, str]
|
The new string and the match. |
Source code in tastymap/utils.py
subset_cmap(cmap, indices, name=None)
¶
Subset a colormap.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmap
|
Colormap
|
A colormap. |
required |
indices
|
int | float | slice | Sequence
|
The indices to subset. |
required |
name
|
str | None
|
The name of the new colormap. |
None
|
Returns:
Type | Description |
---|---|
LinearSegmentedColormap
|
A new colormap. |