def cbox(i, gray=False, spectrum='alternate', reverse=False, as255=False,
    alpha=None, **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
    CD['greenish blue'] = 0.12, 0.8, 0.8
    CD['dark green'] = 0.15, 0.35, 0.0
    CD['yellow'] = 1.0, 1.0, 0.0
    CD['orangish yellow'] = 1.0, 0.9, 0.1
    CD['dark red'] = 0.73, 0.0, 0.0
    CD['dark purple'] = 0.8, 0.0, 0.8
    CD['light green'] = 0.49, 0.64, 0.0
    CD['orange'] = 1.0, 0.5, 0.0
    CD['light blue'] = 0.5, 0.85, 1.0
    CD['pink'] = 1.0, 0.8, 0.8
    CD['brown'] = 0.5, 0.3, 0.0
    CD['red'] = 0.9, 0.0, 0.0
    CD['bluey purple'] = 0.8, 0.85, 1.0
    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:
        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]
    if gray:
        return gray_value, gray_value, gray_value
    if as255:
        rgb = [int(rgb[0] * 255), int(rgb[1] * 255), int(rgb[2] * 255)]
    if alpha:
        rgb = list(rgb)
        rgb.append(alpha)
    return rgb
