Skip to main content
v2026.11,986 entries · CC-BY 4.0

Seaborn Colormaps: Guide to Continuous Color Scales

A research guide to seaborn colormaps: selecting sequential and diverging scales, setting continuous normalizations, and exporting publication figures.

Written and maintained by CASRAI Editorial Board

Published · Last updated

On this page

Seaborn colormaps are continuous color mappings that translate numeric values into smooth color gradients for quantitative scientific visualizations, such as heatmaps, continuous scatter plots, and two-dimensional density estimates. While discrete Seaborn palettes assign distinct qualitative colors to unordered categories, continuous colormaps map quantitative measurements along perceptually uniform luminance and hue scales. Built on top of Matplotlib’s colormap architecture, Seaborn provides native perceptually uniform colormaps—including rocket, mako, flare, crest, vlag, and icefire—while accepting any registered Matplotlib colormap name or custom colormap object via the cmap parameter. Converting any palette into a continuous Matplotlib colormap requires calling sns.color_palette(name, as_cmap=True), which outputs a matplotlib.colors.Colormap object rather than a list of RGB color tuples.

Ask CASRAI · free to tryQuestion about this guide? Ask CASRAI answers with linked sources. 2 free questions a day, no account.

Ask your first question freeSubscribe

What it is used for in research

In quantitative scientific research, visual encoding of continuous variables requires colormaps that accurately reflect the underlying mathematical distribution of data without introducing perceptual artifacts. Traditional rainbow colormaps, such as legacy Jet, suffer from severe non-linearities in perceptual luminance: sudden transitions in brightness create artificial boundaries and visual banding where no gradient exists in the raw measurements, while obscuring subtle local variations in high-saturation zones. Major scientific journals—including Nature, Science, and PNAS—strongly discourage rainbow scales in favor of perceptually uniform colormaps whose perceived brightness scales monotonically with numerical values.

Seaborn continuous colormaps fulfill specific empirical visualization roles across computational and laboratory disciplines:

  • Two-dimensional matrix heatmaps: In genomics, RNA sequencing, and proteomics, researchers visualize gene expression matrices, differential expression fold-changes, and pairwise correlation structures. The native sequential colormaps rocket and mako feature a wide luminance range spanning from near-black to near-white, providing high contrast to differentiate adjacent matrix cells. Detailed matrix implementation is covered in Heatmap in Seaborn.
  • Bipolar and diverging measurements: In clinical trials, metabolomics, and neuroimaging, measurements often diverge around a meaningful baseline, such as zero correlation or baseline change. Seaborn diverging colormaps vlag and icefire provide two balanced hues (blue and red) converging at a neutral center with mathematically symmetrical luminance trajectories, preventing either positive or negative deviations from visually dominating the figure.
  • Continuous scatter plots and bivariate density: In epidemiology, astronomy, and physical chemistry, scatter plots and kernel density estimation (KDE) contours map third continuous dimensions (such as concentration or probability density) to point marks or isolines. For these geometries, flare and crest offer controlled, narrower luminance ranges combined with rich chromatic variation, ensuring point marks remain legible against white figure backgrounds without washing out. Techniques for continuous point mapping are detailed in Scatter Plot in Python.
  • Color-vision deficiency (CVD) accessibility: Approximately 8% of male and 0.5% of female researchers experience red-green color vision deficiency (deuteranomaly or protanomaly). Utilizing colormaps with monotonic luminance slopes ensures figures remain interpretable when viewed by colorblind reviewers or printed in grayscale, adhering to scientific figure rules for journal submission.

Researchers coordinate continuous colormaps alongside categorical palettes. For categorical grouping across experimental arms, refer to Seaborn Color Palettes, while underlying rendering mechanics are documented in Heatmap in Matplotlib and Colorbar in Matplotlib.

How to install or access it

Seaborn is distributed through standard open-source Python package indexes. The official documentation specifies installation via pip from PyPI or via conda through the community-maintained Conda-Forge channel:

# Install via pip
pip install seaborn

# Install via conda from conda-forge
conda install seaborn -c conda-forge

Seaborn requires Python 3.8 or higher and depends on three foundational scientific computing libraries: numpy, pandas, and matplotlib. In reproducible research environments, virtual environments (via venv, conda, or containerized Docker images) should pin specific library versions to ensure deterministic visual output. To verify the installed version and check core dependencies in an interactive shell, execute:

import seaborn as sns
import matplotlib as mpl
import numpy as np
import pandas as pd

print(f"Seaborn version: {sns.__version__}")
print(f"Matplotlib version: {mpl.__version__}")

Step-by-step instructions

Applying, configuring, and exporting continuous colormaps in Seaborn involves eight standardized procedural steps, following official API interfaces:

  1. Select the colormap class: Determine whether data represents a sequential continuum (unipolar values progressing from low to high, such as protein concentrations or cell counts) or a diverging continuum (bipolar values radiating from a critical midpoint, such as correlation coefficients or log2 fold changes). For sequential data, choose rocket, mako, flare, crest, or Matplotlib’s viridis. For diverging data, choose vlag, icefire, or Matplotlib’s coolwarm.
  2. Convert discrete palettes to continuous colormaps with as_cmap: When using Seaborn palette utility functions to supply colormaps to routines expecting a matplotlib.colors.Colormap object, pass as_cmap=True:
    # Generate a continuous colormap object
    continuous_cmap = sns.color_palette("rocket", as_cmap=True)

    When as_cmap=True is passed, the n_colors parameter is ignored because continuous colormaps represent an infinite gradient rather than discrete bins.

  3. Apply sequential colormaps to two-dimensional matrix heatmaps: In sns.heatmap(), pass the colormap name directly via the cmap argument. For unipolar data, Seaborn automatically anchors the minimum and maximum data values to the ends of the colormap:
    import matplotlib.pyplot as plt
    import seaborn as sns
    import numpy as np
    
    # Synthetic experimental matrix
    matrix_data = np.random.exponential(scale=2.0, size=(10, 12))
    
    fig, ax = plt.subplots(figsize=(8, 6))
    sns.heatmap(matrix_data, cmap="mako", ax=ax)
    plt.title("Sequential Matrix Visualization")
  4. Configure diverging colormaps with explicit midpoint centering: When plotting bipolar data with diverging scales like vlag, set the center parameter to guarantee that the neutral midpoint of the colormap aligns with the baseline value (typically zero):
    # Synthetic correlation matrix
    corr_data = np.random.uniform(low=-0.8, high=0.8, size=(8, 8))
    np.fill_diagonal(corr_data, 1.0)
    
    fig, ax = plt.subplots(figsize=(7, 6))
    sns.heatmap(corr_data, cmap="vlag", center=0.0, vmin=-1.0, vmax=1.0, ax=ax)
    plt.title("Diverging Correlation Matrix Centered at Zero")

    Setting vmin=-1.0 and vmax=1.0 ensures visual symmetry, so positive and negative correlations of equal magnitude exhibit identical color intensity.

  5. Protect against experimental outliers with robust quantile scaling: Biological and physical measurements frequently contain extreme outliers that compress the visual dynamic range of remaining data. Setting robust=True computes colormap limits using the 2nd and 98th percentiles rather than absolute minimum and maximum:
    # Heatmap with robust quantile bounds
    sns.heatmap(matrix_data, cmap="rocket", robust=True, ax=ax)
  6. Reverse colormap direction with the _r suffix: Invert any built-in Seaborn or Matplotlib colormap by appending _r to the colormap name string:
    # Reversed sequential colormap where light indicates higher values
    sns.heatmap(matrix_data, cmap="mako_r", ax=ax)
  7. Construct custom continuous colormaps: Seaborn provides constructor functions to generate custom continuous colormaps tailored to specific journal figure requirements:
    • Single-hue sequential colormaps: Use sns.light_palette() or sns.dark_palette() with as_cmap=True:
      custom_light_cmap = sns.light_palette("seagreen", as_cmap=True)
      custom_dark_cmap = sns.dark_palette("#2c3e50", reverse=True, as_cmap=True)
    • Cubehelix colormaps with monotonic grayscale luminance: Use sns.cubehelix_palette() with as_cmap=True or shorthand string notation:
      custom_ch_cmap = sns.cubehelix_palette(start=0.5, rot=-0.75, as_cmap=True)
      # Equivalent string shorthand:
      sns.heatmap(matrix_data, cmap="ch:s=0.5,r=-0.75", ax=ax)
    • Custom diverging colormaps in HUSL space: Use sns.diverging_palette() to specify hue angles for negative and positive poles:
      # Blue (hue 220) to Red (hue 20) with neutral light center
      custom_div_cmap = sns.diverging_palette(h_neg=220, h_pos=20, s=75, l=50, center="light", as_cmap=True)
      sns.heatmap(corr_data, cmap=custom_div_cmap, center=0.0, ax=ax)
  8. Format continuous colorbar labels and figure export: Use cbar_kws to provide publication-ready colorbar annotations, and export figures with vector resolution (PDF or TIFF at 300 DPI):
    fig, ax = plt.subplots(figsize=(8, 6))
    sns.heatmap(
        corr_data,
        cmap="vlag",
        center=0.0,
        vmin=-1.0,
        vmax=1.0,
        cbar_kws={"label": "Pearson Correlation Coefficient (r)"},
        ax=ax
    )
    ax.set_title("Expression Correlation Matrix")
    plt.tight_layout()
    plt.savefig("figure1_colormaps.pdf", dpi=300, bbox_inches="tight")
    plt.close()

Output and how to read it

Interpreting a figure generated with continuous Seaborn colormaps requires analyzing both spatial color distribution and the companion colorbar axis. A properly formatted scientific figure communicates quantitative gradients unambiguously:

  • Reading sequential gradients: In sequential colormaps such as rocket and mako, data values correspond directly to perceived luminance. Darker shades in rocket represent lower numerical values, ascending through magenta and orange tones to bright pale yellow at peak values. In mako, values progress from deep navy blue through cyan to pale green. Because human visual perception is primarily sensitive to luminance contrast, readers naturally perceive darker or brighter regions as quantitative extrema. Verify that the direction of increasing luminance aligns with intuitive interpretation.
  • Reading diverging gradients: In diverging colormaps like vlag, the neutral central color (light gray or off-white) represents baseline or null value (such as zero correlation or no fold-change). Saturated blue tones indicate negative deviation, while saturated red tones indicate positive deviation. The reader assesses both effect direction (hue) and effect magnitude (distance from neutral center toward full saturation).
  • Detecting colormap saturation and clipping: If large contiguous patches of a heatmap or scatter plot exhibit identical maximum or minimum colors, data distribution exceeds specified vmin and vmax bounds. Review colorbar limits to verify whether legitimate variation is flattened at boundaries. If extreme outliers compress the dynamic range of interior data, apply robust=True or perform mathematical transformations (such as log10 transformation for gene expression counts) prior to visualization.
  • Colorbar calibration and tick formatting: The colorbar acts as the visual legend for continuous data. Ensure the colorbar displays explicit numerical tick marks at meaningful intervals (e.g., -1.0, -0.5, 0.0, +0.5, +1.0 for correlation), and verify that the colorbar axis carries a descriptive unit label via cbar_kws={'label': '...'}.

Troubleshooting

When implementing continuous colormaps in Seaborn, researchers commonly encounter five technical configuration issues:

Discrete palette error: Colormap passed where list expected

Passing a continuous colormap object into a function expecting a discrete palette list (such as sns.barplot(..., palette=cmap) or categorical sns.countplot()) raises a ValueError or produces unintended color recycling. Discrete categorical functions expect an iterable list of color tuples. If discrete steps from a continuous colormap are needed, generate them by passing the colormap name and desired color count to sns.color_palette(name, n_colors=k) without setting as_cmap=True.

Extremes clipped or washed out: Adjusting vmin, vmax, and robust

When visual contrast across the central bulk of data appears washed out or monochromatic, a few extreme measurement values are typically anchoring colormap endpoints. Do not manually guess extreme bounds. Instead, pass robust=True to sns.heatmap(), which calculates color mapping limits at the 2nd and 98th quantiles of the dataset. Alternatively, calculate empirical quantiles with NumPy (vmin=np.percentile(data, 1), vmax=np.percentile(data, 99)) and pass them explicitly to prevent outlier distortion.

Reversed colormap orientation: Using the _r suffix

In certain research contexts, higher values should naturally correspond to darker shades (for instance, optical density or radiotracer absorption), whereas default sequential colormaps place lighter shades at the upper bound. Avoid redefining custom colormaps manually to reverse direction. Simply append _r to the colormap name string, such as cmap='rocket_r', cmap='mako_r', or cmap='viridis_r'. For custom colormaps created with sns.light_palette() or sns.dark_palette(), set reverse=True during construction.

Asymmetric data ranges with diverging colormaps: TwoSlopeNorm

Diverging colormaps require special handling when positive and negative data ranges are unequal (for example, log2 fold-changes spanning from -1.5 to +6.0). Setting center=0.0 in sns.heatmap() forces zero to the visual center, but if vmin and vmax are not set symmetrically, Seaborn will map zero to the midpoint while scaling the color gradient unequally across positive and negative sides. To enforce rigorous two-slope normalization, use Matplotlib’s matplotlib.colors.TwoSlopeNorm:

import matplotlib.colors as mcolors

norm = mcolors.TwoSlopeNorm(vcenter=0.0, vmin=-1.5, vmax=6.0)
sns.heatmap(diff_expr_data, cmap="vlag", norm=norm, ax=ax)

This guarantees that zero remains neutral while unit changes in both directions scale proportionately.

Colorbar missing or misaligned in multi-panel subplots

When arranging multi-panel figures with plt.subplots(), calling sns.heatmap() on each subplot automatically generates an independent colorbar on each axis, stealing width from subplots and misaligning multi-panel rows. To share a single unified colorbar across multiple heatmap subplots, set cbar=False on all subplots except the final one, or designate a dedicated axis for the shared colorbar using the cbar_ax argument:

fig, (ax1, ax2, cax) = plt.subplots(1, 3, gridspec_kw={'width_ratios': [1, 1, 0.05]}, figsize=(12, 5))
sns.heatmap(data1, ax=ax1, cbar=False, cmap="mako")
sns.heatmap(data2, ax=ax2, cbar_ax=cax, cmap="mako")

Free alternatives

While Seaborn provides native perceptually uniform colormaps that cover the majority of research requirements, several complementary open-source scientific visualization libraries offer specialized colormap suites. The table below compares free scientific colormap alternatives across Python and R environments.

Library or Tool Colormap Families Key Strengths Primary Research Niche Access and Compatibility
Matplotlib Built-in Colormaps viridis, plasma, inferno, magma, cividis Direct standard library integration; mathematically uniform luminance; cividis optimized for CVD accessibility General physics, engineering, and astronomical data visualization Pre-installed dependency of Seaborn; directly usable via string names in cmap
ColorCET 200+ perceptually uniform colormaps (Peter Kovesi) Comprehensive coverage of cyclic, rainbow-alternative, and isoluminant colormaps Geophysics, radar phase mapping, circular orientation data, and periodic time series Open-source Python package (pip install colorcet); converts directly to Matplotlib/Seaborn colormaps
cmocean thermal, haline, deep, dense, curl, phase Designed specifically for oceanographic and geophysical physical properties Marine science, climate modeling, fluid dynamics, and environmental simulation Open-source Python and MATLAB package; integrated into Matplotlib via matplotlib.colormaps
R viridis / ggplot2 (scale_fill_viridis_c) viridis, magma, plasma, inferno, cividis Native R implementation of perceptually uniform continuous scales for ggplot2 Biostatistics, ecology, and bioinformatics workflows conducted in R Available on CRAN; standard continuous fill scale in ggplot2 graphics pipeline
Scico (Scientific Colormaps by Fabio Crameri) batlow, roma, vik, tokyo, berlin, oleron Strictly perceptually uniform, CVD-safe, un-distorted color palettes across diverse geometries Earth sciences, geodynamics, seismology, and climate research Open-source Python (pip install scico) and R package

Researchers selecting between these libraries should evaluate the dimensional structure of their measurements. For general multidimensional matrix figures in Python, Seaborn native colormaps and Matplotlib core suites provide complete coverage without requiring external dependencies. For specialized directional or cyclic datasets (such as wind direction, phase angle, or diurnal cycles), ColorCET or cmocean phase colormaps provide mathematically verified periodic endpoints.

FAQ

What is the difference between a seaborn palette and a seaborn colormap?

A Seaborn color palette is a discrete sequence of colors (returned as a list of RGB tuples) designed for categorical variables, where each group receives a distinct color. A Seaborn colormap is a continuous mathematical mapping function (an instance of matplotlib.colors.Colormap) that maps a continuous numerical interval to an infinite gradient of colors, designed for continuous numeric variables in heatmaps, scatter plots, and density plots.

How do I make a seaborn palette into a continuous colormap?

To convert a palette into a continuous colormap, call sns.color_palette(name, as_cmap=True). Setting as_cmap=True instructs Seaborn to compile color transitions into a LinearSegmentedColormap or ListedColormap object that can be passed directly to Matplotlib and Seaborn functions accepting a cmap argument.

Which seaborn colormap is best for heatmaps?

For unipolar numeric data in heatmaps, rocket and mako are recommended because they offer an expansive luminance range from near-black to bright white, providing high visual contrast between adjacent matrix cells. For bipolar or diverging heatmaps (such as correlation matrices or differential fold changes), vlag or icefire is best because both provide balanced, perceptually uniform color poles radiating from a neutral center.

Which seaborn colormaps are colorblind-friendly?

All native Seaborn continuous colormaps—including rocket, mako, flare, crest, vlag, and icefire—are perceptually uniform and maintain monotonic or symmetric luminance profiles, ensuring legibility under red-green color vision deficiency (deuteranomaly and protanomaly). In addition, Matplotlib’s cividis colormap, accessible directly in Seaborn via cmap='cividis', was mathematically optimized specifically for complete CVD safety.

How do I reverse a seaborn colormap?

Append the suffix _r to the colormap name string, for example cmap='rocket_r', cmap='mako_r', or cmap='vlag_r'. For custom colormaps created with constructor functions such as sns.light_palette() or sns.dark_palette(), supply the argument reverse=True.

How do I center a diverging colormap at zero in seaborn?

In sns.heatmap(), supply the argument center=0.0 along with a diverging colormap such as cmap='vlag'. To ensure visual balance, pair center=0.0 with symmetric boundary limits using vmin and vmax (such as vmin=-1.0 and vmax=1.0), or use Matplotlib’s matplotlib.colors.TwoSlopeNorm for asymmetric datasets.

Can I use matplotlib colormaps like viridis in seaborn?

Yes. Because Seaborn’s color architecture is built directly on top of Matplotlib, every registered Matplotlib colormap (including viridis, plasma, inferno, magma, cividis, and coolwarm) can be passed directly by name as a string to any Seaborn function that accepts a cmap parameter.

Sources

Data: Continuous Scientific Colormaps Across Python and Open-Source Visualization Libraries

Comparative technical specifications of continuous colormaps across Seaborn, Matplotlib, cmocean, and ColorCET, evaluating color category, perceptual uniformity, color-vision deficiency safety, luminance delta, and primary scientific research use cases.

Period covered: 2024/2026. Coverage: Global.

Continuous Scientific Colormaps Across Python and Open-Source Visualization Libraries
Colormap NameLibraryColor ClassPerceptually UniformCVD SafeLuminance Delta (%)Primary Research Domain
rocketSeabornSequentialYesYes90Gene expression heatmaps and 2D spatial density matrices
makoSeabornSequentialYesYes88Oceanographic depth, physical densities, neural spike rasters
flareSeabornSequentialYesYes50Continuous scatter plots, line curves, and bivariate scatter
crestSeabornSequentialYesYes48Microbiome relative abundance and environmental gradients
vlagSeabornDivergingYesYes65Bipolar correlation matrices and fold-change gene regulation
icefireSeabornDivergingYesYes60Thermal anomalies and dual-pole neuroimaging contrast
viridisMatplotlibSequentialYesYes92Standard general-purpose publication figures and physical simulations
cividisMatplotlibSequentialYesYes85Optimized for red-green color vision deficiency (deuteranomaly/protanomaly)
magmaMatplotlibSequentialYesYes95Astrophysical imaging and high-dynamic-range photon counts
thermalcmoceanSequentialYesYes90Ocean temperature and atmospheric thermodynamics

Sources

Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Seaborn Colormaps: Guide to Continuous Color Scales

2 free questions a day, no account.

An AI assistant for research: funder rules, compliance, methods and publishing. It links the sources behind its answers and labels answers that come from a web search.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays open to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →