import matplotlib as plt
import seaborn as sns
pallete = sns.color_palette("tab10", 3)
In python, this gives the first three colors from the tab10 colormaps. How can I use the other colors? For example, instead of using the first three colors of tab10, I want to use the 1st, 2nd and 4th one. Or, I want to use the 1st, 6th and 8th one. Is it possible? Thank you for your kind concern.
Seaborn's palettes are represented as lists of rgb values. You can use these lists to create a new palette. For example:
import seaborn as sns
palette_tab10 = sns.color_palette("tab10", 10)
palette = sns.color_palette([palette_tab10[0], palette_tab10[1], palette_tab10[3]])
sns.palplot(palette_tab10)
sns.palplot(palette)
To obtain a matplotlib colormap, add as_cmap=True
:
cmap = sns.color_palette([palette_tab10[0], palette_tab10[1], palette_tab10[3]], as_cmap=True)
Seaborn also allows to just provide a list of colors as the palette parameter, e.g.:
sns.palplot(['DeepSkyBlue', palette_tab10[3], 'Chartreuse'])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With