cedalion.vis.colors

Color and colormap definitions.

Functions

mask_cmap([true_is_good, colors])

Create a binary red/blue colormap for boolean quality masks.

p_values_cmap()

A colormap for log10(p-values).

segmented_cmap(name, vmin, vmax, segments[, ...])

Create a linear segmented colormap from (value, color) breakpoints.

threshold_cmap(name, vmin, vmax, threshold)

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,
) tuple[Normalize, LinearSegmentedColormap][source]

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 by vmin/vmax before being passed to LinearSegmentedColormap.

  • 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) — a Normalize instance and the constructed LinearSegmentedColormap.

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'],
) tuple[Normalize, LinearSegmentedColormap][source]

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 when False.

  • colors – Four colours [vmin, threshold-, threshold+, vmax].

Returns:

Tuple (norm, cmap) — a Normalize and the constructed LinearSegmentedColormap.

cedalion.vis.colors.mask_cmap(
true_is_good=True,
colors=['#DC3220', '#DC3220', '#0C7BDC', '#0C7BDC'],
) tuple[Normalize, LinearSegmentedColormap][source]

Create a binary red/blue colormap for boolean quality masks.

Parameters:
  • true_is_good – If True (default), True values are shown in blue (good) and False values in red (bad). Reversed when False.

  • colors – Four colours defining the two-level step ([0, 0.5, 0.5, 1] breakpoints).

Returns:

Tuple (norm, cmap) — a Normalize for [0, 1] and the constructed LinearSegmentedColormap.