#NEWLINE# def _color_palette( cmap , n_colors ) : #NEWLINE# #INDENT# import matplotlib.pyplot as plt #NEWLINE# from matplotlib.colors import ListedColormap #NEWLINE# colors_i = np . linspace ( 0 , 1.0 , n_colors ) #NEWLINE# if isinstance ( cmap , ( list , tuple ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from seaborn.apionly import color_palette #NEWLINE# pal = color_palette ( cmap , n_colors = n_colors ) #NEWLINE# #UNINDENT# except ImportError : #NEWLINE# #INDENT# cmap = ListedColormap ( cmap , N = n_colors ) #NEWLINE# pal = cmap ( colors_i ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( cmap , basestring ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# from seaborn.apionly import color_palette #NEWLINE# pal = color_palette ( cmap , n_colors = n_colors ) #NEWLINE# #UNINDENT# except ( ImportError , ValueError ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cmap = plt . get_cmap ( cmap ) #NEWLINE# #UNINDENT# except ValueError : #NEWLINE# #INDENT# cmap = ListedColormap ( [ cmap ] , N = n_colors ) #NEWLINE# #UNINDENT# pal = cmap ( colors_i ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# pal = cmap ( colors_i ) #NEWLINE# #UNINDENT# #UNINDENT# return pal