cmapgenerator#

Created on Thu Sep 5 15:55:24 2024

@author: Alexandre Kenshilik Coche

cmapgenerator.custom(n_steps, *args)[source]#
args:

color1, color2, color3… en format [Rouge Vert Bleu Alpha] (valeurs entre 0 et 1)

cmapgenerator.custom_2_colors(n_steps, first_color, last_color)[source]#
cmapgenerator.discrete(sequence_name='ibm', alpha=1, black=True, alternate=True, color_format='float')[source]#

Generate a standardized colorscale, based on predefined color maps.

Parameters#

sequence_name{“trio”, “duo”, “uno”, “ibm”, “wong”}, optional, default “ibm”

A flag to choose the colorscale among the available ones.

  • "trio": a 3x9-color scale (+ grays) based on 9 distinct hues.

    • Two other colorscales can be derived from this one:

    • "duo": only the dark and light variations of each hue are returned.

    • "uno": only the middle variation of each hue is returned.

  • "wong": a 9-color scale (+ black) extended from Wong, adapted for colorblindness.

  • "ibm": a 6-color scale (+ black) extended from IBM colorscale, adapted for colorblindness.

alphaNone or float, optional, default 1

Transparency (from 0 to 1). If None, colors are returned without the 4th value.

blackbool, optional, default True

If False, the black color (and related gray variations) are not included in the colorscale.

alternatebool, optional, default True

If True, the colorscale is not in rainbow order.

color_format{“float”, “rbg_str”, “rgba_tuple”}, optional, default “float”

The way to define colors:

  • "float": [0.22, 0.5, 0.99, 0.85]

  • "rgba_str": "rgba(56.1, 127.5, 252.45, 0.82)"

  • "rgba_tuple": (56.1, 127.5, 252.45, 0.82)

Returns#

Return a numpy.array where each row is a 1D-array [red, green, blue, alpha], with values between 0 and 1, or corresponding list with values converted to rgba tuples or strings.

cmapgenerator.to_rgba_str(color)[source]#

This function can convert a color variable of any format ('float', 'rgba_tuple', 'rgba_str') and any shape (one color or several colors) into a color variable in the 'rgba_str' format, for example:

'rgb(239.95, 227.97, 66.045)'

or:

['rgb(239.95, 227.97, 66.045)',
 'rgb(135.92, 33.915, 84.915)',
 'rgb(188.95, 133.11, 254.49)',
 'rgb(212.92, 94.095, 0.51)',
 'rgb(120.105, 195.08, 236.895)']

Parameters#

colorlist, numpy.array, tuple or str

Input color variable to convert.

Returns#

A color variable similar to the input, but in the 'rgba_str' format.