Working with Color Palettes
It is essential to choose the right color for the plot. If your plot looks good, it will be easy to study it.
Setting the Palette
There are two main ways to set colors in Seaborn:
- Global level (
set_palette): this changes the colors for all plots created afterwards. It is useful when you want a consistent style throughout your entire notebook; - Plot level (
paletteargument): this changes colors only for the specific plot.
# 1. Global setting (affects all future plots)
sns.set_palette('mako')
# 2. Local setting (affects only this plot)
sns.countplot(x=data, palette='mako')
Common Palettes
Instead of guessing colors, you can use these built-in Seaborn palette names:
- Categorical (qualitative): best for distinct categories (e.g., fruits, cities).
deep(default);muted;bright;pastel;dark;colorblind.
- Sequential (perceptually uniform): best for showing numeric progression or intensity.
rocket(warm);mako(cool, teal-blue);flare;crest;virdis;rocket_r(adding_rreverses any palette);magma.
You can find the full list of available palettes and color codes in the official Seaborn documentation.
Thanks for your feedback!
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 4.55
Working with Color Palettes
Swipe to show menu
It is essential to choose the right color for the plot. If your plot looks good, it will be easy to study it.
Setting the Palette
There are two main ways to set colors in Seaborn:
- Global level (
set_palette): this changes the colors for all plots created afterwards. It is useful when you want a consistent style throughout your entire notebook; - Plot level (
paletteargument): this changes colors only for the specific plot.
# 1. Global setting (affects all future plots)
sns.set_palette('mako')
# 2. Local setting (affects only this plot)
sns.countplot(x=data, palette='mako')
Common Palettes
Instead of guessing colors, you can use these built-in Seaborn palette names:
- Categorical (qualitative): best for distinct categories (e.g., fruits, cities).
deep(default);muted;bright;pastel;dark;colorblind.
- Sequential (perceptually uniform): best for showing numeric progression or intensity.
rocket(warm);mako(cool, teal-blue);flare;crest;virdis;rocket_r(adding_rreverses any palette);magma.
You can find the full list of available palettes and color codes in the official Seaborn documentation.
Thanks for your feedback!