'Seaborn Color Palette not working appropiate with lineplot

I'm having a little trouble with customizing my colors for a lineplot. I want to show an ensemble of spectras with a sequential color palette. The argument "palette="blues" works fine, but does not accept any appropriate color lists (like "Blues_d"), which do not include any bright colors.

This is a representative graph showing how my plot looks like

Below you can see the code I'm using.

color = (sns.dark_palette("purple"))
sns.set()

ax = sns.lineplot(x="Wavelength", y="Absorption", hue="t (min)", lw=1, data=df1, palette=color, legend="brief")

The problem is, that I get the following error:

ValueError: The palette list has the wrong number of colors.

So the question is: How can I use the lineplot function and using a sequential color palette of blues, reds, or whatever that do not include any bright colors?

I'm using pandas version 0.23.3, matplotlib version 2.2.2 and seaborn version 0.9.0



Solution 1:[1]

No need to worry about the color count if you set your color palette as a color map by setting "as_cmap" argument to True in sns.color_palette:

ax = sns.lineplot(x="Wavelength", 
                      y="Absorption", 
                      hue="t (min)", 
                      lw=1, 
                      data=df1, 
                      palette=sns.color_palette('coolwarm', as_cmap = True), 
                      legend="brief")

Solution 2:[2]

Palette = ["#090364", "#091e75"] #define your preference
sns.set_style("whitegrid")
sns.set_palette(Palette) #use the list defined in the function
plot = sns.countplot(df['Purchased']) #Enjoy ploting

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 PeJota
Solution 2 Ravi kumar