alphapepttools.pl.get_color_mapping

alphapepttools.pl.get_color_mapping#

alphapepttools.pl.get_color_mapping(values, palette)#

Map categorical values to colors.

Maps unique values in values to colors from palette. If palette is a list of colors, colors are assigned in a cycling manner, which can lead to non-unique assignments if there are more unique values than colors in the palette. If palette is a colormap, colors are assigned uniquely based on the number of unique values. Missing values (as defined in config["na_identifiers"]) are assigned the default NA color (config["na_color"]).

Parameters:
  • values (np.ndarray) – Values to map to colors

  • palette (list[str | tuple] | mpl.colors.Colormap) – If palette is a list, it is used as a discrete colormap with cycling colors (potential for non-unique assignment). If palette is a colormap, it is used as a continuous colormap (guaranteed unique assignment).

Return type:

dict

Returns:

dict Dictionary mapping values to colors