In data visualization, selecting appropriate colors can be as important as choosing the right chart type or data representation. Luckily, Python makes it easy to find the right color palette with Seaborn. Read along to understand how to create visualizations that are not only informative but also visually striking and accessible.
If you're new to Python consider starting with either the Introduction to Python course or the Python Programming skill track. These resources will provide you with the necessary skills to follow along with the examples and fully utilize the capabilities of Seaborn.
Quick Note on Color Basics
There are three main elements that define any color: hue, saturation, and value. Each is important because they convey different types of information.
Hue
Hue is what we typically think of as "color" - it's the pure color itself, such as red, blue, or green.

Illustration of hue. Image by Author.
This visual shows different hues, moving through the color wheel from red to purple. Different hues are good for representing categorical data or highlighting specific elements. For example, you might use distinct hues to differentiate between unrelated categories in a bar chart or scatter plot.
Saturation
Saturation refers to the intensity or purity of a color. A fully saturated color is vivid, while a less saturated color appears more muted or gray.

Illustration of saturation. Image by Author.
This gradient shows different levels of saturation for a single hue. The color on the right is fully saturated. As we move left, the color becomes increasingly desaturated, eventually appearing almost gray. More saturated colors can draw attention to key data points or regions of interest.
Value
Value, also known as brightness, refers to the lightness or darkness of a color. Adding white increases the value, while adding black decreases it.

Illustration of value (brightness). Image by Author.
This gradient shows different levels of brightness for the same hue. On the right, we see the color at its brightest. As we move left, the value decreases, with the color becoming darker. Value is useful for showing progression or hierarchy in data. For instance, you might use a value gradient in a heatmap to show the intensity of data across a two-dimensional grid.
Seaborn Color Palette Types
Let's explore the three main types of color palettes in Seaborn: qualitative, sequential, and diverging.
Qualitative palettes using color_palette()
Qualitative palettes are designed for categorical data where there's no inherent ordering or relationship between categories. These palettes use distinct hues to differentiate between categories.

Qualitative palette. Image by Author.
The "Bright" palette shown above is an example of a built-in qualitative palette in Seaborn. It uses distinct, vibrant hues to separate categories. The colors are easily distinguishable from one another, making it ideal for categorical data where there's no inherent order or relationship between categories.
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. When using named palettes (like "pastel" or "Blues"), the number parameter determines how many colors you see. Generally, you match the number of colors to your data categories or create a gradient with a specific number of steps.
For even more precise control, you can use HEX codes to define exact colors. This is especially useful when you need to match specific brand colors or create a unique color scheme not available in the built-in palettes. Here's how you can create different types of palettes using color_palette():
qual_palette = sns.color_palette("pastel", 4)

Creating a qualitative palette with four colors. Image by Author.
seq_palette = sns.color_palette("Blues", 6)

Creating a sequential palette with six colors. Image by Author.
div_palette = sns.color_palette("RdBu", 12)

Creating a diverging palette with 12 colors. Image by Author.
hex = sns.color_palette(["#FF6B6B", "#4ECDC4", "#45B7D1","#FAD02E", "#594F4F"])

Creating a custom palette with HEX codes. Image by Author.
Sequential palettes using cubehelix_palette()
Sequential palettes are ideal for numerical data that has a natural ordering. These palettes show progression from low to high values, typically using variations in lightness and/or saturation of a single hue or multiple hues.

Illustration of Viridis sequential palette. Image by Author.
The "Viridis" palette shows a progression from dark purple to bright yellow. This type of palette is good for showing a range of values from low to high. This would be particularly useful for visualizing continuous data like temperature ranges, population densities, or any dataset where you want to show a clear low-to-high relationship. Other built-in options include: ‘Blues’, ‘Greens’, ‘Reds’, ‘YlOrBr’, and ‘rocket’.
The cubehelix_palette() function allows for the creation of sequential palettes with fine-tuned control over brightness and color progression. This function is particularly useful when you need a palette that smoothly increases in brightness and varies slightly in hue. Here are the parameters for customization:
-
n_colors: The number of colors in the palette.
-
start: The starting position in the color cycle (0-3).
-
rot: Determines how much the hue changes.
-
dark: The darkest color in the palette.
-
light: The lightest color in the palette.
-
reverse: Whether to reverse the direction of the palette.
default_cube = sns.cubehelix_palette(8)

Illustration of default cubehelix palette. Image by Author.
custom_cube = sns.cubehelix_palette(8, start=.5, rot=-.75, dark=.3, light=.8)

Illustration of a custom cubehelix palette. Image by Author.
reversed_cube = sns.cubehelix_palette(8, start=2, rot=0, dark=0, light=.95, reverse=True)

Illustration of a reversed cubehelix palette. Image by Author.
Diverging palettes using diverging_palette()
Diverging palettes are designed for data that has a meaningful midpoint or zero value. These palettes highlight divergence from a central point, using two contrasting hues that become more saturated as values move away from the center.

Illustration of a diverging palette. Image by Author.
The above example effectively illustrates how these palettes highlight divergence from a central point. The palette transitions from cool blues through neutral white to warm reds, with a clear midpoint. This type of palette could be used to visualize temperature anomalies (where 0 represents the average temperature), or profit/loss scenarios in financial data. Other built-in options include: 'RdBu', 'RdYlGn', and 'PiYG'. Let's look at the parameters:
-
h_neg and h_pos: The hues for the negative and positive extents of the palette.
-
n: The number of colors in the palette.
-
s: The saturation of the colors.
-
l: The lightness of the colors.
-
center: The color of the center point ('light' or 'dark').
default_div = sns.diverging_palette(220, 20, n=7)

Illustration of a default diverging palette. Image by Author.
saturated_div = sns.diverging_palette(250, 30, l=65, s=75, n=7)

Diverging palette with more saturation. Image by Author.
dark_center_div = sns.diverging_palette(150, 275, s=80, l=55, n=9, center="dark")

Diverging palette with a darker center. Image by Author.
Final Note on Seaborn Color Palettes
Selecting the right color palette is a critical aspect of creating effective data visualizations. Seaborn's diverse and customizable color palette options provide powerful tools for enhancing the clarity and impact of your data representations.
As you apply these color concepts to your data visualization projects and seek to advance your skills, consider exploring comprehensive learning paths such as the Python Developer or Data Analyst with Python career track. These career-oriented tracks are designed to elevate your proficiency from foundational concepts to more advanced applications, and understanding good visualizations is always important.
In data visualization, selecting appropriate colors can be as important as choosing the right chart type or data representation. Luckily, Python makes it easy to find the right color palette with Seaborn. Read along to understand how to create visualizations that are not only informative but also visually striking and accessible.
If you're new to Python consider starting with either the Introduction to Python course or the Python Programming skill track. These resources will provide you with the necessary skills to follow along with the examples and fully utilize the capabilities of Seaborn.
Quick Note on Color Basics
There are three main elements that define any color: hue, saturation, and value. Each is important because they convey different types of information.
Hue
Hue is what we typically think of as "color" - it's the pure color itself, such as red, blue, or green.
Illustration of hue. Image by Author.
This visual shows different hues, moving through the color wheel from red to purple. Different hues are good for representing categorical data or highlighting specific elements. For example, you might use distinct hues to differentiate between unrelated categories in a bar chart or scatter plot.
Saturation
Saturation refers to the intensity or purity of a color. A fully saturated color is vivid, while a less saturated color appears more muted or gray.
Illustration of saturation. Image by Author.
This gradient shows different levels of saturation for a single hue. The color on the right is fully saturated. As we move left, the color becomes increasingly desaturated, eventually appearing almost gray. More saturated colors can draw attention to key data points or regions of interest.
Value
Value, also known as brightness, refers to the lightness or darkness of a color. Adding white increases the value, while adding black decreases it.
Illustration of value (brightness). Image by Author.
This gradient shows different levels of brightness for the same hue. On the right, we see the color at its brightest. As we move left, the value decreases, with the color becoming darker. Value is useful for showing progression or hierarchy in data. For instance, you might use a value gradient in a heatmap to show the intensity of data across a two-dimensional grid.
Seaborn Color Palette Types
Let's explore the three main types of color palettes in Seaborn: qualitative, sequential, and diverging.
Qualitative palettes using color_palette()
Qualitative palettes are designed for categorical data where there's no inherent ordering or relationship between categories. These palettes use distinct hues to differentiate between categories.
Qualitative palette. Image by Author.
The
"Bright"palette shown above is an example of a built-in qualitative palette in Seaborn. It uses distinct, vibrant hues to separate categories. The colors are easily distinguishable from one another, making it ideal for categorical data where there's no inherent order or relationship between categories.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. When using named palettes (like"pastel"or"Blues"), thenumberparameter determines how many colors you see. Generally, you match the number of colors to your data categories or create a gradient with a specific number of steps.For even more precise control, you can use HEX codes to define exact colors. This is especially useful when you need to match specific brand colors or create a unique color scheme not available in the built-in palettes. Here's how you can create different types of palettes using
color_palette():Creating a qualitative palette with four colors. Image by Author.
Creating a sequential palette with six colors. Image by Author.
Creating a diverging palette with 12 colors. Image by Author.
Creating a custom palette with HEX codes. Image by Author.
Sequential palettes using cubehelix_palette()
Sequential palettes are ideal for numerical data that has a natural ordering. These palettes show progression from low to high values, typically using variations in lightness and/or saturation of a single hue or multiple hues.
Illustration of Viridis sequential palette. Image by Author.
The
"Viridis"palette shows a progression from dark purple to bright yellow. This type of palette is good for showing a range of values from low to high. This would be particularly useful for visualizing continuous data like temperature ranges, population densities, or any dataset where you want to show a clear low-to-high relationship. Other built-in options include:‘Blues’,‘Greens’,‘Reds’,‘YlOrBr’, and‘rocket’.The
cubehelix_palette()function allows for the creation of sequential palettes with fine-tuned control over brightness and color progression. This function is particularly useful when you need a palette that smoothly increases in brightness and varies slightly in hue. Here are the parameters for customization:n_colors: The number of colors in the palette.start: The starting position in the color cycle (0-3).rot: Determines how much the hue changes.dark: The darkest color in the palette.light: The lightest color in the palette.reverse: Whether to reverse the direction of the palette.Illustration of default cubehelix palette. Image by Author.
Illustration of a custom cubehelix palette. Image by Author.
Illustration of a reversed cubehelix palette. Image by Author.
Diverging palettes using diverging_palette()
Diverging palettes are designed for data that has a meaningful midpoint or zero value. These palettes highlight divergence from a central point, using two contrasting hues that become more saturated as values move away from the center.
Illustration of a diverging palette. Image by Author.
The above example effectively illustrates how these palettes highlight divergence from a central point. The palette transitions from cool blues through neutral white to warm reds, with a clear midpoint. This type of palette could be used to visualize temperature anomalies (where 0 represents the average temperature), or profit/loss scenarios in financial data. Other built-in options include:
'RdBu','RdYlGn', and'PiYG'. Let's look at the parameters:h_negandh_pos: The hues for the negative and positive extents of the palette.n: The number of colors in the palette.s: The saturation of the colors.l: The lightness of the colors.center: The color of the center point ('light'or'dark').Illustration of a default diverging palette. Image by Author.
Diverging palette with more saturation. Image by Author.
Diverging palette with a darker center. Image by Author.
Final Note on Seaborn Color Palettes
Selecting the right color palette is a critical aspect of creating effective data visualizations. Seaborn's diverse and customizable color palette options provide powerful tools for enhancing the clarity and impact of your data representations.
As you apply these color concepts to your data visualization projects and seek to advance your skills, consider exploring comprehensive learning paths such as the Python Developer or Data Analyst with Python career track. These career-oriented tracks are designed to elevate your proficiency from foundational concepts to more advanced applications, and understanding good visualizations is always important.