def _n_colors(n, bytes_=False, cmap='hsv'):
 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] == c), 1)):
    raise RuntimeError(('Could not get %d unique colors from %s colormap. Try using a different colormap.' % (n, cmap)))
 return colors

def _n_colors ( n , bytes_ = False , cmap = 'hsv' ) : 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 ] == c ) , 1 ) ) : raise RuntimeError ( ( 'Could not get %d unique colors from %s colormap. Try using a different colormap.' % ( n , cmap ) ) ) return colors
produce a list of n unique rgba color tuples based on a colormap .