You can use the optional argument palette, such as in (see here):

sns.pairplot(data, kind="scatter", hue = "Class", palette = "Paired")

In this case, I chose the color palette "Paired", but there are many others. You could also use:

sb.set_palette("dark")
sns.pairplot(data, kind="scatter", hue = "Class")

You can learn more about the available color palettes in the Seaborn site, https://seaborn.pydata.org/tutorial/color_palettes.html.

Answer from Maria on Stack Overflow
🌐
Seaborn
seaborn.pydata.org › generated › seaborn.color_palette.html
seaborn.color_palette — seaborn 0.13.2 documentation
set_color_codes · Reassign color codes like "b", "g", etc. to colors from one of the seaborn palettes. Examples · Calling with no arguments returns all colors from the current default color cycle: sns.color_palette() Other variants on the seaborn categorical color palette can be referenced by name: sns.color_palette("pastel") Return a specified number of evenly spaced hues in the “HUSL” system: sns.color_palette("husl", 9) Return all unique colors in a categorical Color Brewer palette: sns.color_palette("Set2") Return a diverging Color Brewer palette as a continuous colormap: sns.color_p
🌐
Codecademy
codecademy.com › article › seaborn-design-ii
Seaborn Color Palettes: Complete Guide to Data Visualization Colors | Codecademy
Using sns.set() not only applies the Seaborn default color palette but also enables its grid style, font scaling, and other formatting enhancements.
🌐
GeeksforGeeks
geeksforgeeks.org › seaborn-color-palette
Seaborn - Color Palette - GeeksforGeeks
sns.set_palette("Set2"): This sets the color palette to "Set2", one of Seaborn's predefined color palettes.
Published: April 8, 2025
🌐
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 - It is possible to give a list of colors you want to use in your plots as a parameter to set_palette function. ... # library & dataset import seaborn as sns import matplotlib.pyplot as plt df = sns.load_dataset('iris') # use the 'palette' argument ...
🌐
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 - # Set the color palettesns.set_palette(sns.color_palette("Paired"))# Plot the data, specifying a different color for data points in# each of the day categories (weekday and weekend)ax = sns.scatterplot(x='day', y='miles_walked', data=dataset, hue='day_category')# Customize the axes and titleax.set_title("Miles walked")ax.set_xlabel("day")ax.set_ylabel("total miles")# Remove top and right bordersax.spines['top'].set_visible(False)ax.spines['right'].set_visible(False)plt.show()
🌐
APXML
apxml.com › courses › data-visualization-matplotlib-seaborn › chapter-4-seaborn-enhanced-visuals-intro › seaborn-color-palettes
Using Seaborn Color Palettes
Scatter plot showing random data points colored by categories 'A', 'B', and 'C' using the 'bright' Seaborn palette. If you want to use the same palette for multiple plots in your script or notebook without specifying it each time, you can use seaborn.set_palette(). import seaborn as sns import matplotlib.pyplot as plt import pandas as pd import numpy as np # Create sample data np.random.seed(10) data = pd.DataFrame({ 'category': ['X', 'Y', 'Z', 'X', 'Y', 'Z', 'X', 'Y'], 'value': np.random.rand(8) * 10 }) # Set the default palette to 'pastel' sns.set_palette("pastel") # Create a bar plot - it w
Find elsewhere
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 $0.11$ 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.
🌐
GeeksforGeeks
geeksforgeeks.org › data visualization › changing-plot-colors-in-seaborn-a-comprehensive-guide
Changing Plot Colors in Seaborn : A Comprehensive Guide - GeeksforGeeks
July 11, 2024 - You can define custom colors using hex codes or RGB values for precise control over your plot's appearance. ... custom_palette = ["#090364", "#091e75", "#093885", "#085396", "#086da6", "#0888b7", "#08a2c7", "#07bdd8", "#07d7e8", "#07f2f9", ...
🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › boxplot › control colors in a seaborn boxplot
Control colors in a Seaborn boxplot
2 weeks ago - Specifying colors 'by hand' is quickly performed by creating a dictionnary composed of category: color pairs as key:value, such as we did in the following example with my_pal. ... # libraries & dataset import seaborn as sns import matplotlib.pyplot as plt sns.set_theme(style="darkgrid") df = sns.load_dataset("iris") my_pal = {"versicolor": "g", "setosa": "b", "virginica": "m"} sns.boxplot(hue=df["species"], y=df["sepal_length"], palette=my_pal) plt.show()
🌐
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 - Seaborn’s color palettes are built on a sequence of color specifications. These can be: Hex color code (e.g., ‘#FF5733’) import seaborn as sns import matplotlib.pyplot as plt # Define your custom colors custom_colors = ['#FF5733', '#FFB933', '#99e2b4', '#33A2FF', '#a663cc'] # Set the custom palette sns.set_palette(custom_colors) # Sample data for the bar…
🌐
TutorialsPoint
tutorialspoint.com › seaborn › seaborn_set_palette_method.htm
Seaborn.set_palette() method
In the below example, we will pass ice fire as the color palette to the set_palette() method and draw a plot to see the color palette. import seaborn as sns import matplotlib.pyplot as plt titanic=sns.load_dataset("titanic") titanic.head() ...
🌐
DataCamp
datacamp.com › tutorial › seaborn-palettes
Seaborn Color Palette: Quick Guide to Picking Colors | DataCamp
September 30, 2024 - # Create a sequential palette with 6 colors seq_palette = sns.color_palette("Blues", 6)
🌐
LinuxTut
linuxtut.com › en › c79c9973a92e1e2c77a7
How to choose a Seaborn color palette
March 1, 2016 - %matplotlib inline import seaborn as sns, numpy as np from ipywidgets import interact, FloatSlider · --color_palette can be used to create most color palettes. You can use set_palette to set the default color palette (see below for an example).
🌐
Python Graph Gallery
python-graph-gallery.com › the python graph gallery › heatmap › control color in seaborn heatmaps
Control color in seaborn heatmaps
2 weeks ago - You can customize the colors in your heatmap with the cmap parameter of the heatmap() function in seaborn. The following examples show the appearences of different sequential color palettes.