Binning and ramp helpers for monochrome heatmaps.
A heatmap renders a 2D grid of numeric values as shaded cells. In a monochrome world, shading comes from hatch density — we quantize each value to one of N levels, then fill each cell with the pattern assigned to that level.
The default ramp walks from paper-white to full black in seven steps, with hatch orientation alternating to keep adjacent levels distinguishable even under poor reproduction:
:solid_white → :dots_sparse → :diagonal → :crosshatch
→ :diagonal_dense → :dots_dense → :solid_blackYou can override with any list of pattern preset atoms, or use the
ramp/1 helper to truncate or extend.
iex> Bland.Heatmap.quantize(0.5, {0.0, 1.0}, 4)
2
iex> Bland.Heatmap.quantize(-1.0, {0.0, 1.0}, 4)
0
Summary
Functions
The default 7-level ramp, light to dark.
Returns {min, max} of a nested list of numbers, ignoring non-numbers.
Maps value in {lo, hi} to a discrete level in [0, n_levels).
Returns a ramp of exactly n levels by sampling evenly from the
default ramp.
Functions
@spec default_ramp() :: [atom()]
The default 7-level ramp, light to dark.
Returns {min, max} of a nested list of numbers, ignoring non-numbers.
iex> Bland.Heatmap.extent([[1, 2], [3, 4]])
{1, 4}
@spec quantize(number(), {number(), number()}, pos_integer()) :: non_neg_integer()
Maps value in {lo, hi} to a discrete level in [0, n_levels).
Values <= lo clamp to 0, values >= hi clamp to n_levels - 1.
@spec ramp(pos_integer()) :: [atom()]
Returns a ramp of exactly n levels by sampling evenly from the
default ramp.
iex> Bland.Heatmap.ramp(3)
[:solid_white, :crosshatch, :solid_black]