Skip to content

ColorScale

deckgl_marimo.ColorScale

Map a numeric data column to interpolated colors.

Produces per-row RGBA color arrays by mapping values from a numeric column through a color ramp. Use with any get_*_color accessor.

Parameters:

Name Type Description Default
column str

Name of the numeric column to map.

required
colors list[str | list[int]] | None

List of 2+ colors to interpolate between. Each color can be a CSS name ("blue"), hex string ("#FF0000"), or RGB list ([255, 0, 0]). Mutually exclusive with palette.

None
palette str | None

Name of a built-in palette. Available: "viridis", "plasma", "inferno", "magma", "cividis", "coolwarm", "RdBu", "spectral", "turbo". Mutually exclusive with colors.

None
domain tuple[float, float] | None

(min, max) value range. If None, auto-detected from data.

None
scale str

Scale type: "linear" (default) or "log".

'linear'
alpha int

Alpha channel value (0-255) for all output colors.

255

Examples:

>>> layer = ScatterplotLayer(
...     data=df,
...     get_fill_color=ColorScale("temperature", palette="viridis"),
... )
>>> layer = ScatterplotLayer(
...     data=df,
...     get_fill_color=ColorScale("value", colors=["blue", "red"], scale="log"),
... )
Notes

ColorScale requires materialized data. If the layer's data is a URL string, :meth:resolve raises ValueError — load the URL into a DataFrame or list of dicts first, or pre-compute colors and pass them as a regular column.

resolve

resolve(data)

Resolve to per-row RGBA arrays for JSON transfer.

Parameters:

Name Type Description Default
data Any

Layer data (DataFrame, list of dicts, GeoJSON dict, etc.)

required

Returns:

Type Description
list[list[int]]

Per-row [R, G, B, A] color arrays.

resolve_numpy

resolve_numpy(data)

Resolve to a numpy uint8 array of shape (n, 4) for binary transfer.

Parameters:

Name Type Description Default
data Any

Layer data (DataFrame, list of dicts, GeoJSON dict, etc.)

required

Returns:

Type Description
ndarray

RGBA colors as uint8 array with shape (n, 4).