Access a modular list of colors for plotting.
    Defines colours using rgb.

    :param i: (int), index to access color
    :param gray: (bool), if true then color is return as grayscale value
    :param spectrum: (str), choice of spectrum to use
    :param reverse: (bool), reverses the color order
    :param kwargs:
    :return:

def cbox(i, gray=False, spectrum="alternate", reverse=False, **kwargs):
    """
    Access a modular list of colors for plotting.
    Defines colours using rgb.

    :param i: (int), index to access color
    :param gray: (bool), if true then color is return as grayscale value
    :param spectrum: (str), choice of spectrum to use
    :param reverse: (bool), reverses the color order
    :param kwargs:
    :return:
    """

    CD = {}
    CD['dark blue'] = (0.0, 0.0, 0.55)  # 0
    CD['greenish blue'] = (0.12, .8, .8)  # 10
    CD['dark green'] = (0.15, 0.35, 0.0)  # 1
    CD['yellow'] = (1.0, 1.0, 0.0)  # 6
    CD['orangish yellow'] = (1.0, 0.9, 0.1)  # 6
    CD['dark red'] = (0.73, 0.0, 0.0)  # 2
    CD['dark purple'] = (0.8, 0.0, 0.8)  # 3
    CD['light green'] = (0.49, 0.64, 0.0)  # 4
    CD['orange'] = (1.0, 0.5, 0.0)  # 5
    CD['light blue'] = (0.5, 0.85, 1.0)  # 6
    CD['pink'] = (1.0, 0.8, 0.8)  # 7
    CD['brown'] = (0.5, 0.3, 0.0)  # 8
    CD['red'] = (0.9, 0.0, 0.0)  # 9

    CD['bluey purple'] = (0.8, 0.85, 1.0)  # 12

    CD['dark gray'] = (0.25, 0.25, 0.25)  #
    CD['mid gray'] = (0.5, 0.5, 0.5)  #
    CD['light gray'] = (0.75, 0.75, 0.75)  #
    CD['dark grey'] = (0.25, 0.25, 0.25)  #
    CD['mid grey'] = (0.5, 0.5, 0.5)  #
    CD['light grey'] = (0.75, 0.75, 0.75)  #
    CD['black5'] = (0.05, 0.05, 0.05)  #
    CD['black'] = (0.0, 0.0, 0.0)  #
    CD['white'] = (1.0, 1.0, 1.0)  #

    if isinstance(i, int):
        i = i
    elif isinstance(i, float):
        i = int(i)
    elif isinstance(i, str):
        dat = CD[i]
        return dat
    if spectrum == "alternate":
        order = ['dark blue', 'orange', 'light blue', 'dark purple', 'dark green',
                 'bluey purple', 'dark red', 'light green', 'pink', 'brown',
                 'red', 'yellow', 'greenish blue', 'dark gray',
                 'mid gray', 'light gray']
    elif spectrum == "lighten":
        order = ['dark blue', 'dark green', 'dark red', 'brown',
                 'light green', 'orange', 'light blue', 'pink', 'dark purple',
                 'red', 'greenish blue', 'bluey purple', 'yellow',
                 'dark gray', 'mid gray', 'light gray']
    elif spectrum == 'dots':
        order = ['dark blue', 'yellow', 'light blue', 'dark purple', 'dark green', 'orange',
                 'bluey purple', 'dark red', 'light green', 'pink', 'brown',
                 'red', 'greenish blue', 'dark gray',
                 'mid gray', 'light gray']
    elif spectrum == "traffic":
        order = ['dark green', 'orange', 'red']
    else:  # warnings
        order = ['light green', 'orangish yellow', 'orange', 'red', 'black', 'dark gray']

    index = i % len(order)
    if reverse:
        index = len(order) - index - 1
    rgb = CD[order[index]]

    gray_value = 0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]  # calculate the gray scale value

    if gray:
        return gray_value, gray_value, gray_value

    return rgb