utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:hdhp.py 作者: Networks-Learning 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号