Skip to main content

Module bivariate

Module bivariate 

Source
Expand description

Bivariate fill scale: two binned variables → an n × m palette (biscale-style; Stevens 1994’s bivariate-choropleth method), backing a ::BIVARIATE choropleth. Ported from the design in anofox-visualization’s docs/plans/plan-maps.md (§15, D10) — DataZooDE/ anofox-visualization#318, #182.

The binning itself (computing each variable’s tertile/class index) is the caller’s job, same as super::binned::ScaleFillBinned’s break maths — this scale only colours an already-binned composite class. Follow the biscale R package’s own convention: a composite class is a 1-indexed "{x_class}-{y_class}" string (e.g. "3-2" = x-tertile 3, y-tertile 2), the value a bi_class()-style data-prep step would put in a fill column.

Structs§

ScaleFillBivariate
Bivariate fill scale: nx × ny classes, each class "{i}-{j}" (1-indexed) coloured by bivariate_cell_color. See the module docs.

Functions§

bivariate_cell_color
The colour for class (i, j) (0-indexed) of an nx × ny grid: each channel of base is pulled toward the matching channel of color_x by tx = i/(nx-1) and toward color_y by ty = j/(ny-1), subtracted (not averaged) so the two axes compound rather than cancel — base − tx·(base − color_x) − ty·(base − color_y), clamped to 0..=255. At (0, 0) this is exactly base; at (nx-1, 0) exactly color_x; at (0, ny-1) exactly color_y; at the high-high corner the two subtractions compound (usually clamping low), the classic bivariate-choropleth “dark/saturated corner” look. base is the low-low cell’s colour — white for a light theme; pass a theme’s card colour for a “lifted over the card colour” dark variant (plan-maps.md §15’s D10) instead of guessing a theme from inside this crate.