Two classes for querying colors

class plot_utils.Color(color, is_rgb_normalized=True)[source]

A class that defines a color.

Parameters:
  • color (str or <tuple> or <list>) – The color information to initialize the Color object. Can be a list or tuple of 3 elements (i.e., the RGB information), or a HEX string such as “#00FF00”, or XKCD color names (https://xkcd.com/color/rgb/) or X11 color names (http://cng.seas.rochester.edu/CNG/docs/x11color.html).

  • is_rgb_normalized (bool) – Whether or not the input information (if RGB) contains the normalized values (such as [0, 0.5, 0.5]). This parameter has no effect if the input is not RGB.

as_hex()[source]

Exports the color object as HEX values.

Returns:

hex_val – HEX value.

Return type:

str

as_rgb(normalize=True)[source]

Export thes color as RGB values.

Parameter

normalizebool

Whether or not to return the normalized (between 0 and 1) RGB.

returns:

rgb_val – RGB values in three numbers.

rtype:

tuple<float>

as_rgba(alpha=1.0)[source]

Exports the color object as RGBA values. The R, G, and B values are always normalized (between 0 and 1).

Parameter

alphafloat

The transparency (0 being completely transparent and 1 opaque).

returns:

rgba_val – RGBA values in four numbers.

rtype:

tuple<float>

show()[source]

Shows color as a square patch.

class plot_utils.Multiple_Colors(colors, is_rgb_normalized=True)[source]

A class that defines multiple colors.

Parameters:
  • colors (list) –

    A list of color information to initialize the Multiple_Colors object. The list elements can be:

    Different elements of colors do not need to be of the same type.

  • is_rgb_normalized (bool) – Whether or not the input information (if RGB) contains the normalized values (such as [0, 0.5, 0.5]). This parameter has no effect if the input is not RGB.

as_hex()[source]

Exports the colors as a list of HEX values

Returns:

hex_list – A list of HEX colors

Return type:

list<str>

as_rgb(normalize=True)[source]

Exports the colors as a list of RGB values

Parameter

normalizebool

Whether or not to return the normalized (between 0 and 1) RGB.

returns:

rgb_list – A list of list: each sub-list represents a RGB color in three numbers.

rtype:

list<list<float>>

as_rgba(alpha=1.0)[source]

Exports the colors as a list of RGBA values

Parameter

alphafloat

The transparency (0 being completely transparent and 1 opaque).

returns:

rgba_list – A list of list: each sub-list represents a RGBA color in four numbers.

rtype:

list<list<float>>

show(vertical=False, text=None)[source]

Shows the colors as square patches

Parameters:
  • vertical (bool) – Whether or not to show the patches vertically

  • text (str) – The text to show next to the colors