Black Lives Matter. Please consider donating to Black Girls Code today.

Built-in Continuous Color Scales in Python

A reference for the built-in named continuous (sequential, diverging and cylclical) color scales in Plotly.

New to Plotly?

Plotly is a free and open-source graphing library for Python. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

Using Built-In Continuous Color Scales

Many Plotly Express functions accept a color_continuous_scale argument and many trace types have a colorscale attribute in their schema. Plotly comes with a large number of built-in continuous color scales, which can be referred to in Python code when setting the above arguments, either by name in a case-insensitive string e.g. px.scatter(continuous_color_scale="Viridis") or by reference e.g. go.Scatter(marker_colorscale=plotly.colors.sequential.Viridis). They can also be reversed by adding _r at the end e.g. "Viridis_r" or plotly.colors.sequential.Viridis_r.

The plotly.colours module is also available under so you can refer to it as px.colors.

When using continuous color scales, you will often want to configure various aspects of its range and colorbar.

Discrete Color Sequences

Plotly also comes with some built-in discrete color sequences which are not intended to be used with the color_continuous_scale argument as they are not designed for interpolation to occur between adjacent colors.

Named Built-In Continuous Color Scales

You can use any of the following names as string values to set continuous_color_scale or colorscale arguments. These strings are case-insensitive and you can append _r to them to reverse the order of the scale.

In [1]:
import as px
from textwrap import wrap

named_colorscales = px.colors.named_colorscales()
print("\n".join(wrap("".join('{:<12}'.format(c) for c in named_colorscales), 96)))
aggrnyl     agsunset    blackbody   bluered     blues       blugrn      bluyl       brwnyl
bugn        bupu        burg        burgyl      cividis     darkmint    electric    emrld
gnbu        greens      greys       hot         inferno     jet         magenta     magma
mint        orrd        oranges     oryel       peach       pinkyl      plasma      plotly3
pubu        pubugn      purd        purp        purples     purpor      rainbow     rdbu
rdpu        redor       reds        sunset      sunsetdark  teal        tealgrn     viridis
ylgn        ylgnbu      ylorbr      ylorrd      algae       amp         deep        dense
gray        haline      ice         matter      solar       speed       tempo       thermal
turbid      armyrose    brbg        earth       fall        geyser      prgn        piyg
picnic      portland    puor        rdgy        rdylbu      rdylgn      spectral    tealrose
temps       tropic      balance     curl        delta       edge        hsv         icefire
phase       twilight    mrybm       mygbm

Built-in color scales are stored as lists of CSS colors:

In [2]:
import as px

['#0d0887', '#46039f', '#7201a8', '#9c179e', '#bd3786', '#d8576b', '#ed7953', '#fb9f3a', '#fdca26', '#f0f921']

Built-In Sequential Color scales

A collection of predefined sequential colorscales is provided in the plotly.colors.sequential module. Sequential color scales are appropriate for most continuous data, but in some cases it can be helpful to use a diverging or cyclical color scale (see below).

Here are all the built-in scales in the plotly.colors.sequential module:

In [3]:
import as px

fig = px.colors.sequential.swatches()

Note: RdBu was included in this module by mistake, even though it is a diverging color scale. It is intentionally left in for backwards-compatibility reasons.

Built-In Diverging Color scales

A collection of predefined diverging color scales is provided in the plotly.colors.diverging module. Diverging color scales are appropriate for continuous data that has a natural midpoint other otherwise informative special value, such as 0 altitude, or the boiling point of a liquid. These scales are intended to be used when explicitly setting the midpoint of the scale.

Here are all the built-in scales in the plotly.colors.diverging module:

In [4]:
import as px

fig = px.colors.diverging.swatches().update_layout(margin_b=10)

Built-In Cyclical Color scales

A collection of predefined cyclical color scales is provided in the plotly.colors.cyclical module. Cyclical color scales are appropriate for continuous data that has a natural cyclical structure, such as temporal data (hour of day, day of week, day of year, seasons) or complex numbers or other phase or angular data.

Here are all the built-in scales in the plotly.colors.cyclical module:

In [5]:
import as px

fig = px.colors.cyclical.swatches_cyclical()

fig = px.colors.cyclical.swatches()

What About Dash?

Dash is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.

Learn about how to install Dash at

Everywhere in this page that you see, you can display the same figure in a Dash application by passing it to the figure argument of the Graph component from the built-in dash_core_components package like this:

import plotly.graph_objects as go # or as px
fig = go.Figure() # or any Plotly Express function e.g.
# fig.add_trace( ... )
# fig.update_layout( ... )

import dash
import dash_core_components as dcc
import dash_html_components as html

app = dash.Dash()
app.layout = html.Div([

app.run_server(debug=True, use_reloader=False)  # Turn off reloader if inside Jupyter