Seaborn Color Palette: A Practical Guide for Python Charts
How to use seaborn color palettes in Python — built-in palettes, sequential vs diverging, colorblind-safe options, and custom palettes from hex codes.
If you build charts in Python, the seaborn color palette system is one of the easiest ways to make your visualisations look professional. Seaborn — the popular statistical plotting library built on Matplotlib — ships with a thoughtful set of palettes and makes it simple to apply your own. This guide covers the built-in options, when to use each type, and how to plug in custom colours from hex codes.
Need a custom set of hex colours to feed into seaborn? Generate and copy one in seconds on the PaletteCSS palette browser.
Seaborn's built-in palettes
Seaborn includes six core qualitative palettes for categorical data: deep, muted, pastel, bright, dark, and colorblind. You can preview any of them in a couple of lines:
import seaborn as sns
# Preview a palette
sns.palplot(sns.color_palette("deep"))
# Set it as the default for all plots
sns.set_palette("muted")
Calling sns.color_palette() with no arguments returns the current default palette, which is handy for checking what you are working with.
Qualitative vs sequential vs diverging
Choosing the right type of palette matters more than the exact colours. Seaborn supports all three:
- Qualitative — for unordered categories (e.g. countries, product types). Use
deep,muted, orcolorblind. - Sequential — for data that goes from low to high (e.g. temperature). Use
"Blues","viridis", or"rocket". - Diverging — for data with a meaningful midpoint (e.g. profit vs loss). Use
"coolwarm"or"vlag".
# Sequential palette for a heatmap
sns.heatmap(data, cmap="viridis")
# Diverging palette centred on zero
sns.heatmap(data, cmap="coolwarm", center=0)
Using a custom palette from hex codes
This is where a tool like PaletteCSS comes in. Pick a palette, copy the hex codes, and pass them straight to seaborn:
my_colors = ["#FF6B6B", "#FFD56B", "#43C59E", "#3A86FF", "#8338EC"]
# Use it once
sns.barplot(data=df, x="group", y="value", palette=my_colors)
# Or set it as the global default
sns.set_palette(sns.color_palette(my_colors))
This is the fastest way to match your charts to a brand palette — design the colours visually, then drop the hex list into your code.
Make your charts colorblind-safe
Roughly one in twelve men has some form of colour-vision deficiency, so accessibility matters in data viz. Seaborn's colorblind palette and the perceptually-uniform viridis family are both excellent, safe defaults:
sns.set_palette("colorblind")
Tips for better seaborn palettes
- Match palette type to data. Never use a qualitative palette for ordered data — it hides the trend.
- Limit categories. Qualitative palettes get hard to read past 8–10 colours.
- Stay consistent. Use
sns.set_palette()once so every chart in a report matches. - Prefer viridis for heatmaps. It is colourblind-safe and prints well in greyscale.
Frequently asked questions
How do I set a color palette in seaborn?
Use sns.set_palette("muted") for a global default, or pass palette= to an individual plot. For custom colours, pass a list of hex codes.
What is the default seaborn palette?
Seaborn's default qualitative palette is deep. You can see it any time with sns.color_palette().
Can I use my own hex colors in seaborn?
Yes. Pass a list like ["#FF6B6B", "#3A86FF"] to palette= or to sns.set_palette(). Generate one on PaletteCSS and copy the hex codes.
Build your chart palette. Create a custom colour set on PaletteCSS, copy the hex codes, and drop them straight into seaborn.