survive.utils.check_colors

survive.utils.check_colors(colors, *, n_colors=None, keys=None, palette=None)[source]

Validate colors for plotting.

Parameters:
colors : list or tuple or dict or str

Colors for each key. This is ignored if palette is provided. Possible types:

list or tuple

Sequence of valid Matplotlib colors to cycle through.

dict

If parameter keys is not None, this should be a mapping from the keys in keys to valid Matplotlib colors.

str

Name of a Matplotlib colormap. The parameter n_colors must be provided in this case to specify how many colors to generate.

n_colors : int, optional

Specify the number of colors to generate.

keys : sequence, optional

List of all keys that must be present in colors if it is a dict.

palette : str, optional

Name of a seaborn color palette. Requires seaborn to be installed. Setting a color palette overrides the colors parameter.

Returns:
colors : iterable

Iterable of colors to cycle through.