I figured it out. You had to paste the number of colors into the palette:

sns.set_style("whitegrid")
plot = sns.scatterplot(df.loc[:,'length'], 
                       df.loc[:,'type'],
                       hue = df.loc[:,'temperature'],
                       palette=sns.color_palette(palette, len(palette)),
                       legend = False, 
                       s = 200)


                   
Answer from Anavae on Stack Overflow
🌐
Noga H. Rotman
r02b.github.io › seaborn_palettes
Seaborn Color Palettes and How to Use Them | Noga H. Rotman
November 8, 2022 - The matlab default palette we all know and love is called tab10, and is also the default palette for most seaborn functions. The seaborn variations are: deep, muted, pastel, bright, dark, and colorblind, while the matplotlib palettes are tab20, ...
Top answer
1 of 2
27

I figured it out. You had to paste the number of colors into the palette:

sns.set_style("whitegrid")
plot = sns.scatterplot(df.loc[:,'length'], 
                       df.loc[:,'type'],
                       hue = df.loc[:,'temperature'],
                       palette=sns.color_palette(palette, len(palette)),
                       legend = False, 
                       s = 200)


                   
2 of 2
0

In newer Seaborn versions (≥0.11) you can use:

colors = ["#090364", "#091e75", "#093885", "#085396", "#086da6", 
           "#0888b7", "#08a2c7", "#07bdd8", "#07d7e8", "#07f2f9", 
           "#f9ac07", "#c77406", "#963b04", "#640303"]

sns.set_style("whitegrid")

plot = sns.scatterplot(
    x='length', 
    y='type',
    hue='temperature',
    legend=False, 
    palette=sns.color_palette(colors),
    s=200,
    data=df)

The reason why your custom palette isn’t picked by Seaborn is that sns.set_palette() only sets the default color cycle for plots that don't use the hue semantic.

When you use hue=… in Seaborn, data points are categorised using different colors based on the hue variable and its categories (or levels). For instance, if hue='temperature', Seaborn extracts all unique distinct values in the 'temperature' column.

Here’s the thing: you need to specify a color for each of these hue levels and it’s up to you to make sure that your custom palette has the correct number of colors.

From your code I can also tell that you’re using an older version of Seaborn, certainly pre because starting from version 0.11:

Most plotting functions now require all of their parameters to be specified using keyword arguments.

(quote from https://seaborn.pydata.org/whatsnew/v0.11.0.html#required-keyword-arguments)

So the positional arguments

plot = sns.scatterplot(
    df.loc[:,'length'], 
    df.loc[:,'type'],

in newer Seaborn versions should be given as

plot = sns.scatterplot(
    x=df.loc[:,'length'], 
    y=df.loc[:,'type'],

Here's a demo with an extra improvement of the original code (using data=df so that the columns can be specified just by their name):

import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

# Create a simple sample DataFrame
np.random.seed(0)
temperature_levels = [f'Temp{i:02d}' for i in range(14)]  # 14 unique temps

df = pd.DataFrame({
    'length': np.random.rand(100) * 10,
    'type': np.random.rand(100) * 5,  
    'temperature': np.random.choice(temperature_levels, size=100)
})

# 14 colors
colors = ["#090364", "#091e75", "#093885", "#085396", "#086da6", 
           "#0888b7", "#08a2c7", "#07bdd8", "#07d7e8", "#07f2f9", 
           "#f9ac07", "#c77406", "#963b04", "#640303"]

sns.set_style("whitegrid")

plot = sns.scatterplot(
    x='length', 
    y='type',
    hue='temperature',
    legend=False, 
    palette=sns.color_palette(colors),
    s=200,
    data=df)

What happens if the number of colors doesn't match the number of hue levels?

If the palette contains more colors than there are unique temperature values, Seaborn will ignore the extra colors. You may also see a warning like this:
UserWarning: The palette list has more values (14) than needed (10), which may not be intended.

If the number of hue levels is larger than the number of colors in your palette, Seaborn will cicle on the colors thus creating unwanted effects. You may also see a warning like this:

The palette list has fewer values (14) than needed (43) and will cycle, which may produce an uninterpretable plot.
Discussions

Creating Custom Seaborn Color Palettes from ONLY two Hex Codes? [Question]
import seaborn as sns from matplotlib.colors import LinearSegmentedColormap from matplotlib.cm import register_cmap # relative positions of colors in cmap/palette pos = [0.0,1.0] colors=['#3877C7','#C75B38'] cmap = LinearSegmentedColormap.from_list("", list(zip(pos, colors))) register_cmap("my_cmap", cmap) palette= sns.color_palette("my_cmap",n_colors=50) sns.palplot(palette) plt.show() More on reddit.com
🌐 r/learnpython
2
1
July 5, 2020
All seaborn color palettes together, so you don't have to search for them everytime
Would have been nice if they are sorted in diverging colormaps, selective ones etc. More on reddit.com
🌐 r/visualization
13
119
October 20, 2021
Python data visualization library seaborn's polite way of asking have I've lost all good chromatic sense

Excell default color palette. Much better than it used to be, but still cringey.

More on reddit.com
🌐 r/visualization
8
25
May 17, 2016
TIL that seaborn refuses to use the jet color scheme in a most wonderful fashion

Here is why jet is a bad color map: http://jakevdp.github.io/blog/2014/10/16/how-bad-is-your-colormap/

tl;dr; It was once the default for matplotlib, but it sucks because the colors lie to you. The perceived luminance of the gradient jumps all over the place and you might see highlights and features that simply are not there.

More on reddit.com
🌐 r/Python
92
1346
June 9, 2018
🌐
Codecademy
codecademy.com › article › seaborn-color-palettes-complete-guide-to-data-visualization-colors
Seaborn Color Palettes: Complete Guide to Data Visualization Colors | Codecademy
An example of this is as follows: ... To select and set a palette in Seaborn, use the command sns.set_palette() and pass in the name of the palette that you would like to use: ... Before customizing your palettes, it’s helpful to understand ...
🌐
Medium
medium.com › @gozdemadendere › python-seaborn-creating-your-own-color-palettes-606559c61a7d
Python Seaborn: Creating Your Own Color Palettes | by Gözde Madendere | Medium
August 8, 2023 - It helps convey information, highlight patterns, and evoke emotions. Seaborn, a powerful data visualization library in Python, allows you to create custom color palettes that align with your data and visual storytelling goals.
🌐
Towards Data Science
towardsdatascience.com › home › data science › how to use your own color palettes with seaborn
How to use your own color palettes with Seaborn | Towards Data Science
August 22, 2019 - This will result in the same plot as above! But now you can use the same color palette by referring to customPalette in any of your seaborn plots.
🌐
Seaborn
seaborn.pydata.org › tutorial › color_palettes.html
Choosing color palettes — seaborn 0.13.2 documentation
Seaborn includes two perceptually uniform diverging palettes: "vlag" and "icefire". They both use blue and red at their poles, which many intuitively processes as “cold” and “hot”: ... You can also use the seaborn function diverging_palette() to create a custom colormap for ...
Find elsewhere
🌐
YouTube
youtube.com › watch
Seaborn Color Palette Basics | Using named and custom color palettes in Python seaborn - YouTube
Explore seaborn color palettes with this video tutorial on seaborn palette options. We start with the basics of seaborn's default color palette through the ...
Published: August 23, 2021
🌐
Datavizpyr
datavizpyr.com › home › how to change colors in seaborn (custom palettes and manual colors)
How to Change Colors in Seaborn (Custom Palettes and Manual Colors) - Data Viz with Python and R
August 25, 2025 - Seaborn automatically selects a palette when you map a variable to hue. This default is great for quick exploration and ensures high baseline readability. In this section, you’ll see how Seaborn colors categories without any extra configuration.
🌐
Reddit
reddit.com › r/learnpython › creating custom seaborn color palettes from only two hex codes? [question]
r/learnpython on Reddit: Creating Custom Seaborn Color Palettes from ONLY two Hex Codes? [Question]
July 5, 2020 -

Hi,

I am wondering if it is possible to create custom diverging seaborn color palettes by only giving it the starting and end colors.

So as an example, If I wanted Hex Code '#3877C7' to be the negative value and '#C75B38' to be the positive, is there a way to tell seaborn (or anything) this and have it automatically fill in the rest of the colors?

I know you can create custom palettes if you list off every combo you want, but that seems very manual if you are changing the two end colors often.

Thanks!

🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › scatterplot › selecting color palettes with seaborn
Selecting Color Palettes with Seaborn
2 weeks ago - In order to set the colors move from lighther to darker in a sequential color palette, you should give palette parameter in your plot function. If you want the reverse order of colors (darker to lighter), you can simply add the suffix "_r" to ...
🌐
Michael Blow
michaeljblow.com › blog › 8ge0hmdkeo0emaz342rplolujpns91
Custom Color Palettes for Seaborn Plots — Michael Blow
March 11, 2020 - Seaborn includes palettes from colorbrewer2.org. SImply call up seaborn_colorbrewer_palette with either the sequential, diverging, or qualitative options and a widget will appear ready for customization!
🌐
DataCamp
datacamp.com › tutorial › seaborn-palettes
Seaborn Color Palette: Quick Guide to Picking Colors | DataCamp
September 30, 2024 - The color_palette() function is Seaborn’s way of creating custom color palettes. It allows you to switch between these different types of palettes by changing the palette name and the number of colors.
🌐
Medium
onealchhetri.medium.com › creating-custom-palette-in-seaborn-2f2fe706bc28
Creating Custom Palette in Seaborn | by Anil Kumar Chhetri | Medium
July 23, 2020 - In Color palette function we can choose palette name or sequence of color, number of colors, and desaturate value of color. If the number of colors defined in the palette is less than the number of colors chosen then we get repeated color.
🌐
Pythoncharts
pythoncharts.com › seaborn › seaborn-custom-color-palettes
Python Charts - Setting Custom Color Palettes in Seaborn
August 13, 2026 - Pass a list of hex codes straight to palette, one color per category. import matplotlib.pyplot as plt import seaborn as sns custom_colors = ["#264653", "#2a9d8f", "#e9c46a", "#f4a261", "#e76f51", "#a8dadc"] fig, ax = plt.subplots() sns.barplot(data=df, x="category", y="revenue", hue="category", palette=custom_colors, legend=False, ax=ax)
🌐
EDUCBA
educba.com › home › data science › data science tutorials › seaborn tutorial › seaborn palette
Seaborn Palette | How to Create Colors Seaborn Palette with FAQ?
March 16, 2023 - We know that seaborn is the library based on a matplotlib. We need to create our custom data to use the palette’s custom colors.
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Rich Hildebrand
richardhildebrand.wordpress.com › 2019 › 09 › 18 › create-a-custom-color-palette-with-matplotlib-and-seaborn
Create a custom color palette with matplotlib and seaborn | Rich Hildebrand
October 11, 2019 - import numpy as np; np.random.seed(0) import seaborn as sns; sns.set() import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap, LinearSegmentedColormap def create_color(r, g, b): return [r/256, g/256, b/256] def get_custom_color_palette(): return LinearSegmentedColormap.from_list("", [ create_color(227, 101, 33), create_color(246, 145, 53), create_color(251, 168, 74), create_color(218, 212, 200), create_color(141, 193, 223), create_color(114, 167, 208), create_color(43, 92, 138) ]) low, high = -5, 15 data = np.random.uniform(low, high, (10, 15)) cmap = get_custom_color_palette() sns.heatmap(data, cmap=cmap, center=0);
🌐
GeeksforGeeks
geeksforgeeks.org › changing-plot-colors-in-seaborn-a-comprehensive-guide
Changing Plot Colors in Seaborn : A Comprehensive Guide - GeeksforGeeks
July 11, 2024 - Seaborn offers several built-in color palettes and allows for extensive customization. The primary methods to change colors in Seaborn plots include using the color parameter for single colors and the palette parameter for multiple colors.
🌐
PaletteCSS
palettecss.com › home › blog › seaborn color palette: a practical guide for python charts
Seaborn Color Palette: A Practical Guide for Python Charts
June 26, 2026 - Need a custom set of hex colours to feed into seaborn? Generate and copy one in seconds on the PaletteCSS palette browser. Seaborn includes six core qualitative palettes for categorical data: deep, muted, pastel, bright, dark, and colorblind.