

def _n_colors(n, bytes_=False, cmap='hsv'):
    'Produce a list of n unique RGBA color tuples based on a colormap\n\n    Parameters\n    ----------\n    n : int\n        Number of colors.\n    bytes : bool\n        Return colors as integers values between 0 and 255 (instead of floats\n        between 0 and 1).\n    cmap : str\n        Which colormap to use.\n\n    Returns\n    -------\n    colors : array, shape (n, 4)\n        RGBA color values.\n    '
    n_max = (2 ** 10)
    if (n > n_max):
        raise NotImplementedError(("Can't produce more than %i unique colors" % n_max))
    from matplotlib.cm import get_cmap
    cm = get_cmap(cmap, n_max)
    pos = np.linspace(0, 1, n, False)
    colors = cm(pos, bytes=bytes_)
    if bytes_:
        for (ii, c) in enumerate(colors):
            if np.any(np.all((colors[:ii] == cm), 1)):
                raise RuntimeError(('Could not get %d unique colors from %s colormap. Try using a different colormap.' % (n, cmap)))
    return colors

dataset/ETHPy150Open mne-tools/mne-python/mne/label.py _n_colors/VarMisuse@125/319 `c`->`cm`