Skip to content

Diverging schemes

Diverging color schemes are available as continuous interpolators (often used with d3.scaleSequential) and as discrete schemes (often used with d3.scaleOrdinal).

Each discrete scheme, such as d3.schemeBrBG, is represented as an array of arrays of hexadecimal color strings. The kth element of this array contains the color scheme of size k; for example, d3.schemeBrBG[9] contains an array of nine strings representing the nine colors of the brown-blue-green diverging color scheme. Diverging color schemes support a size k ranging from 3 to 11.

To create a diverging continuous color scale using the PiYG color scheme:

js
const color = d3.scaleSequential(d3.interpolatePiYG);

To create a diverging discrete nine-color scale using the PiYG color scheme:

js
const color = d3.scaleOrdinal(d3.schemePiYG[9]);

interpolateBrBG(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “BrBG” diverging color scheme represented as an RGB string.

interpolatePRGn(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “PRGn” diverging color scheme represented as an RGB string.

interpolatePiYG(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “PiYG” diverging color scheme represented as an RGB string.

interpolatePuOr(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “PuOr” diverging color scheme represented as an RGB string.

interpolateRdBu(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “RdBu” diverging color scheme represented as an RGB string.

interpolateRdGy(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “RdGy” diverging color scheme represented as an RGB string.

interpolateRdYlBu(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “RdYlBu” diverging color scheme represented as an RGB string.

interpolateRdYlGn(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “RdYlGn” diverging color scheme represented as an RGB string.

interpolateSpectral(t)

Source · Given a number t in the range [0,1], returns the corresponding color from the “Spectral” diverging color scheme represented as an RGB string.

schemeBrBG[k]

Source · The “BrBG” discrete diverging color scheme of size k in 3–11.

schemePRGn[k]

Source · The “PRGn” discrete diverging color scheme of size k in 3–11.

schemePiYG[k]

Source · The “PiYG” discrete diverging color scheme of size k in 3–11.

schemePuOr[k]

Source · The “PuOr” discrete diverging color scheme of size k in 3–11.

schemeRdBu[k]

Source · The “RdBu” discrete diverging color scheme of size k in 3–11.

schemeRdGy[k]

Source · The “RdGy” discrete diverging color scheme of size k in 3–11.

schemeRdYlBu[k]

Source · The “RdYlBu” discrete diverging color scheme of size k in 3–11.

schemeRdYlGn[k]

Source · The “RdYlGn” discrete diverging color scheme of size k in 3–11.

schemeSpectral[k]

Source · The “Spectral” discrete diverging color scheme of size k in 3–11.