colors module

colors.display_color_strip(color_family, fc_bg='w')

A quick way to print a strip of colors given a list of colors

Parameters
  • color_family (List) – List of names of colors that Matplotlib recognizes. Typically, from CSS4.colors

  • fc_bg (color) – A single color to use as the background. Defaults to ‘white’

colors.get_color_sequence(n: int = 6, attr: str = None, order: str = 'incr', start_color=None, step: int = 1) → List

Returns a List of Color names, based on arguments specified

If you specify a low and high you can pick the colors from a specific range of CSS4 Colors

Parameters
  • n (int, optional) – number of colors desired. Default is 6. If n is 1, just the color_name is return, not a list

  • attr (str, optional) – Must be one of [‘random’, ‘hue’, ‘sat|uration’, ‘value’, ‘dark’, ‘light’] or a color family name. If ‘random,’ then order is ignored. Default attr is hue

  • order (str, optional) – Must be either ‘incr|easing’ or ‘decr|easing.’ Default order is “increasing”

Returns

List of n colors . Each element of the list is a color name. If n is 1, then just the name is returned, not a List.

Return type

List

Examples

>>> get_color_sequence()
['red', 'mistyrose', 'salmon', 'tomato', 'darksalmon', 'coral']
>>> get_color_sequence(1)
'oldlace'
>>> get_color_sequence(n=5, attr='Sat', order='incr')
['coral', 'orangered', 'lightsalmon', 'sienna', 'seashell']
>>> get_color_sequence(n=3, attr='hue', order='incr', step=4)
['red', 'darksalmon', 'sienna']
colors.get_key_given_item(v, _dict: Dict)

Get list of keys from a dictionary, given its value. Reverse lookup

colors.get_n_random_color_families(n: int = 2) → List

Returns a specified number n of randomly selected color families

Parameters

n (int) – number of color families desired

Returns

List of n color families. each Element (COLOR FAMILY) is a list of color names

Return type

List

colors.get_next_color(color_list, col_index, p_next=0.1, use_color_families=False, curr_fam_index=0, p_next_fam=0)
colors.get_random_color(n: int = 1, low: int = 0, high: int = 148) → List

Get a completely random color

If you specify a low and high you can pick the colors from a specific range of CSS4 Colors

Parameters
  • n (int) – number of colors desired. Default is 1. If n is 1, just the color_name is return, not a list

  • low (int) – lower end to pick range of mcolornames (Default is 0)

  • high (int) – upper end to pick range of mcolornames (Default is 148)

Returns

List of n colors . Each element is a color name

Return type

List

colors.get_random_color_from_family(cfamily)

Will return one colorname from the input list of colors

Parameters

cfamily (List) – List of names of colors

colors.get_random_colorfamily()

Will return one COLOR_Family

colors.print_color_family_names(cfams)

Print the Color Family Name instead of printing out each element

This function is useful when logging the colors used, especially if color families are fetched randomly.

Parameters

cfams (List) – One or more Color Families, pre-specified. Each element is a list of colornames