Extract RGB or 6 digit code from Seaborn palette

后端 未结 2 1665
南旧
南旧 2021-02-18 20:11

Seaborn has an option to create nice color palettes. I wish to use these palettes to generate colors that work well together in a map where countries are shaded according to som

相关标签:
2条回答
  • 2021-02-18 20:19

    If by "6 digit code" you mean a hex code, you can also do:

    pal = sns.color_palette(...)
    pal.as_hex()
    
    0 讨论(0)
  • 2021-02-18 20:22

    The values you are getting are percentages of 255, the max RGB value. Just multiply each triplet of values by 255 (and round off, if you like) to get the RGB values.

    for color in color_list:
        for value in color:
            value *= 255
    

    Then store those in a new list to have your list of RGB values.

    0 讨论(0)
提交回复
热议问题