#NEWLINE# def gencolor( N , colormap = 'Set1' ) : #NEWLINE# #INDENT# '\n    Color generator intended to work with one of the ColorBrewer\n    qualitative color scales.\n\n    Suggested values of colormap are the following:\n\n        Accent, Dark2, Paired, Pastel1, Pastel2, Set1, Set2, Set3\n\n    (although any matplotlib colormap will work).\n    ' #NEWLINE# from matplotlib import cm #NEWLINE# n_colors = min ( N , 9 ) #NEWLINE# cmap = cm . get_cmap ( colormap , n_colors ) #NEWLINE# colors = cmap ( range ( n_colors ) ) #NEWLINE# for i in xrange ( N ) : #NEWLINE# #INDENT# ( yield i [ ( i % n_colors ) ] )