def gencolor(N, colormap='Set1'):
    from matplotlib import cm
    # don't use more than 9 discrete colors
    n_colors = min(N, 9)
    cmap = cm.get_cmap(colormap, n_colors)
    colors = cmap(range(n_colors))
    for i in xrange(N):
        yield colors[i % n_colors]
Color generator intended to work with one of the ColorBrewer
dataset/ETHPy150Open geopandas/geopandas/geopandas/plotting.py/gencolor