cedalion.vis.colors
Color and colormap definitions.
Functions
|
Create a binary red/blue colormap for boolean quality masks. |
A colormap for log10(p-values). |
|
|
Create a linear segmented colormap from (value, color) breakpoints. |
|
Create a red-and-blue colormap with a sharp break at a quality threshold. |
- cedalion.vis.colors.segmented_cmap(
- name: str,
- vmin: float,
- vmax: float,
- segments: list[tuple[float, tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float]]],
- over: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
- under: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
- bad: None | tuple[float, float, float] | str | tuple[float, float, float, float] | tuple[tuple[float, float, float] | str, float] | tuple[tuple[float, float, float, float], float] = None,
Create a linear segmented colormap from (value, color) breakpoints.
- Parameters:
name – Name for the colormap (used by matplotlib internally).
vmin – Data value corresponding to the bottom of the colormap.
vmax – Data value corresponding to the top of the colormap.
segments – List of
(value, color)pairs defining the colour breakpoints. Values are normalised byvmin/vmaxbefore being passed toLinearSegmentedColormap.over – Color for out-of-range values above
vmax(optional).under – Color for out-of-range values below
vmin(optional).bad – Color for masked/NaN values (optional).
- Returns:
Tuple
(norm, cmap)— aNormalizeinstance and the constructedLinearSegmentedColormap.
- cedalion.vis.colors.p_values_cmap() tuple[Normalize, LinearSegmentedColormap][source]
A colormap for log10(p-values).
Gray for p>0.05 and with different colors for common thresholds.
- cedalion.vis.colors.threshold_cmap(
- name,
- vmin,
- vmax,
- threshold,
- higher_is_better=True,
- colors=['#000000', '#DC3220', '#5D3A9B', '#0C7BDC'],
Create a red-and-blue colormap with a sharp break at a quality threshold.
- Parameters:
name – Colormap name.
vmin – Minimum data value.
vmax – Maximum data value.
threshold – Value at which the colour transitions sharply.
higher_is_better – If
True(default), colours below the threshold are “bad” (warm) and colours above are “good” (cool). Reversed whenFalse.colors – Four colours
[vmin, threshold-, threshold+, vmax].
- Returns:
Tuple
(norm, cmap)— aNormalizeand the constructedLinearSegmentedColormap.
- cedalion.vis.colors.mask_cmap(
- true_is_good=True,
- colors=['#DC3220', '#DC3220', '#0C7BDC', '#0C7BDC'],
Create a binary red/blue colormap for boolean quality masks.
- Parameters:
true_is_good – If
True(default),Truevalues are shown in blue (good) andFalsevalues in red (bad). Reversed whenFalse.colors – Four colours defining the two-level step (
[0, 0.5, 0.5, 1]breakpoints).
- Returns:
Tuple
(norm, cmap)— aNormalizefor[0, 1]and the constructedLinearSegmentedColormap.