Skip to content

发散方案

🌐 Diverging schemes

发散颜色方案可以作为连续插值器使用(通常与 d3.scaleSequential 一起使用),也可以作为离散方案使用(通常与 d3.scaleOrdinal 一起使用)。

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

每个离散方案,例如 d3.schemeBrBG,都表示为十六进制颜色字符串数组的数组。该数组的第 k 个元素包含大小为 k 的配色方案;例如,d3.schemeBrBG[9] 包含一个由九个字符串组成的数组,表示棕-蓝-绿发散配色方案的九种颜色。发散配色方案支持的大小 k 范围是 3 到 11。

🌐 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.

要使用 PiYG 配色方案创建发散连续色度量表:

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

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

使用 PiYG 配色方案创建发散的九色离散色标:

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

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

interpolateBrBG(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“BrBG”分叉配色方案对应的颜色,以 RGB 字符串表示。

interpolatePRGn(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“PRGn”发散配色方案对应的颜色,以 RGB 字符串表示。

interpolatePiYG(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“PiYG”发散配色方案对应的颜色,以 RGB 字符串表示。

interpolatePuOr(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“PuOr”分叉配色方案对应的颜色,以 RGB 字符串表示。

interpolateRdBu(t)

🌐 interpolateRdBu(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“RdBu”分叉配色方案对应的颜色,以 RGB 字符串表示。

interpolateRdGy(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“RdGy”发散配色方案对应的颜色,以 RGB 字符串表示。

interpolateRdYlBu(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“RdYlBu”分散色彩方案中对应的颜色,以 RGB 字符串表示。

interpolateRdYlGn(t)

🌐 interpolateRdYlGn(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“RdYlGn”分隔色彩方案中对应的颜色,以 RGB 字符串表示。

interpolateSpectral(t)

来源 · 给定范围在 [0,1] 内的数字 t,返回“光谱”分叉配色方案对应的颜色,以 RGB 字符串表示。

schemeBrBG[k]

来源 · 尺寸为 k 的“BrBG”离散分歧色彩方案,范围为 3–11。

schemePRGn[k]

来源 · 尺寸为 k 的 “PRGn” 离散发散配色方案,范围为 3–11。

schemePiYG[k]

来源 · 尺寸为 k 的 “PiYG” 离散发散配色方案,范围为 3–11。

schemePuOr[k]

来源 · 尺寸为 k 的“PuOr”离散发散色彩方案,范围为 3–11。

schemeRdBu[k]

来源 · 尺寸为 k 的“RdBu”离散分歧配色方案,范围为 3–11。

schemeRdGy[k]

来源 · 尺寸为 k 的 “RdGy” 离散发散配色方案,范围为 3–11。

schemeRdYlBu[k]

来源 · 3–11尺寸的“RdYlBu”离散发散色彩方案,大小为k

schemeRdYlGn[k]

来源 · 3–11 尺寸的“RdYlGn”离散发散颜色方案,大小为 k

schemeSpectral[k]

来源 · 尺寸为 k 的“光谱”离散发散颜色方案,范围为 3–11。