def qualitative_cmap(n_colors=17):
"""Returns a colormap suitable for a categorical plot with many categories.
Parameters
----------
n_colors : int, default is 17
The number of colors that, usually, matches with the number of
categories.
Returns
-------
list
A list of hex colors.
"""
set1 = sns.mpl_palette("Set1", n_colors=9)
hex_colors = [rgb2hex(rgb) for rgb in set1]
hex_colors[5] = '#FFDE00'
if n_colors <= 9:
return hex_colors
if n_colors <= 17:
n_colors = 17
else:
n_colors = 8 * ceil((n_colors - 1) / 8)
gradient = polylinear_gradient(hex_colors, n_colors)
return gradient
评论列表
文章目录