SciFig
Guides··6 min read

Viridis Color Palette: Hex Codes Reference

Viridis hex codes at 5, 8, and 10 steps, why it stays readable in grayscale and for colorblind readers, plus copy-ready R, Python, and CSS snippets.

SciFig Team
SciFig Team
Scientific Illustration Experts

Viridis is a perceptually uniform colormap for continuous scientific data.

It runs from dark purple to bright yellow, and unlike the rainbow maps it replaced, equal steps in your data produce equal-looking steps in color. That property is what makes it safe for heatmaps, density plots, and any scientific figure where readers estimate values from color. This page gives the hex codes at the sampling densities you actually need.

The viridis colormap shown as a continuous gradient bar above discrete 5, 8, and 10 step samples with hex codes labeled (Viridis swatch chart rendered by SciFig)
The viridis colormap shown as a continuous gradient bar above discrete 5, 8, and 10 step samples with hex codes labeled (Viridis swatch chart rendered by SciFig)

Viridis Hex Codes at 5, 8, and 10 Steps

Viridis is defined as a continuous colormap, so there is no single canonical list of hex values. What you sample depends on how many categories or contour levels you need. The values below are taken from the matplotlib reference implementation, sampled at evenly spaced positions from 0.0 to 1.0.
StepsHex codes
5#440154 #3B528B #21918C #5EC962 #FDE725
8#440154 #46327E #365C8D #277F8E #1FA187 #4AC16D #A0DA39 #FDE725
10#440154 #482878 #3E4989 #31688E #26828E #1F9E89 #35B779 #6ECE58 #B5DE2B #FDE725
The endpoints are always #440154 (dark purple) and #FDE725 (bright yellow). The intermediate values change with the number of steps — the 8-step and 10-step lists are not subsets of each other. If you quote viridis hex codes anywhere, state how many steps you sampled, or the numbers will not reproduce.

See Figure Enhancement in Action

Upscale, recolor, or relabel any existing scientific figure to 8K journal-ready quality.

Explore the Tool

Why Perceptual Uniformity Matters

The classic rainbow colormap has bands where color changes fast and bands where it barely changes at all. Readers perceive the fast-changing bands as sharp boundaries in the data even when the data is smooth, and they miss real structure inside the slow-changing bands. The colormap invents features and hides others.

Viridis was designed to avoid this. Lightness increases monotonically from one end to the other, and the rate of perceived change stays roughly constant across the range. Two consequences follow directly:

  • It survives grayscale. Because lightness is monotonic, converting to grayscale preserves the ordering. A rainbow map does not — its middle is often lighter than both ends.
  • It survives color vision deficiency. The ordering is carried mostly by lightness rather than by a red-green contrast, so the reading stays intact.
A density plot rendered in rainbow and in viridis side by side, with grayscale conversions beneath each showing the rainbow version losing its ordering (Comparison figure generated with SciFig)
A density plot rendered in rainbow and in viridis side by side, with grayscale conversions beneath each showing the rainbow version losing its ordering (Comparison figure generated with SciFig)

Copy-Ready Code

Python

import matplotlib.pyplot as plt
plt.imshow(data, cmap="viridis")
 
# discrete sampling
from matplotlib import cm
from matplotlib.colors import to_hex
import numpy as np
hexes = [to_hex(cm.get_cmap("viridis")(x)).upper()
         for x in np.linspace(0, 1, 8)]

R

library(viridis)
scale_fill_viridis_c()          # continuous
scale_fill_viridis_d()          # discrete
viridis(8)                      # hex vector

CSS

.viridis-gradient {
  background: linear-gradient(
    to right,
    #440154, #46327E, #365C8D, #277F8E,
    #1FA187, #4AC16D, #A0DA39, #FDE725
  );
}
Viridis sampled at 5, 8, and 10 steps stacked to show that intermediate colours shift with the step count (Viridis swatch chart rendered by SciFig)
Viridis sampled at 5, 8, and 10 steps stacked to show that intermediate colours shift with the step count (Viridis swatch chart rendered by SciFig)

When Not to Use Viridis

Viridis is a sequential map. It encodes "more" and "less" along a single direction. It is the wrong choice in two common cases:
  • Unordered categories. Treatment groups and species have no natural order. Sampling viridis for them implies a ranking that does not exist. Use a qualitative palette such as Okabe-Ito instead.
  • Data diverging around a meaningful midpoint. Log fold change, temperature anomaly, and correlation all have a neutral center. A sequential map hides it. Use a diverging scheme with a neutral middle.
There is also a readability caveat: the dark end of viridis is very dark. Thin lines and small markers in #440154 on a white background can read as plain black. For line plots with few series, a qualitative palette usually communicates better.

Tip

Viridis has siblings built on the same principle — magma, inferno, plasma, and cividis. Cividis is specifically optimized so that people with and without color vision deficiency perceive nearly the same image, which makes it a strong default for figures aimed at broad audiences.

A heatmap and a contour plot using viridis with a labeled colorbar showing the mapping between values and colors (Figure generated with SciFig)
A heatmap and a contour plot using viridis with a labeled colorbar showing the mapping between values and colors (Figure generated with SciFig)

Create Scientific Figures Now

Describe your scientific figure in natural language — get publication-ready illustrations in minutes.

Try Free
To apply a colormap to an existing figure without regenerating the underlying plot, figure enhancer can recolor it directly, and the scientific color palette generator helps pick between sequential, diverging, and qualitative before you commit.

Related reading: Best Color Palettes for Scientific Figures (2026), Nature-Level Scientific Figures on a Budget.

FAQ

Recommended next

Related scientific figure resources

Go deeper with the most relevant SciFig pages for this article.

Call to action background

Ready to start?

Publication-ready scientific figures, in minutes

Start Creating Free

Free to start · No credit card required · Built for researchers