Facet
Small multiples: one cell per category, per field, or per pair of fields (a scatterplot matrix).
Static preview; loading the interactive plot
<script>
import { Facet, Plot, Points } from "hmplot";
const data = {
x: [1, 2, 3, 4, 1, 2, 3, 4],
y: [3, 1, 4, 2, 2, 4, 1, 3],
group: ["a", "a", "a", "a", "b", "b", "b", "b"],
};
</script>
<Facet {data} column="group">
<Plot height={300} axes2d>
<Points x="x" y="y" />
</Plot>
</Facet>
Usage
row/column choose partition fields; wrap is for single-field layouts. Shared domains are the default for categories, link defaults to auto, linking the shared axes, which the grid labels once on its outer cells. Cells preserve camera and settings by category identity. A transform inside the facet runs per subset.
Fields and pairs
fields={["temp", "rain"]} makes one cell per field over the same rows. Inside a cell, value is the cell’s field (its identity, metadata and scales: a strip brush on it constrains the field itself) and field holds the field’s name, one categorical column across the cells. A list lays the cells along columns ({column: [...]} says so explicitly); {row: [...]} stacks them; a categorical split may take the other dimension (fields={[...]} row="species"), and on the same dimension is an error. The order of the fields dimension (columnOrder for a list) picks and orders the fields; a name that is not one of them is an empty cell. pairs={["a", "b", "c"]} is a scatterplot matrix whose cells alias x and y to their two fields, with triangle (“full”, “upper”, “lower”) and diagonal; pairs={{x: [...], y: [...]}} is rectangular (columns from x, rows from y). as renames the aliases ({value, field} or {x, y}) when the table has columns of those names, which the aliases otherwise hide inside the cells. With fields or pairs, scales default to "field": a field keeps one domain across the cells (and across x and y in pairs), columns of the table stay shared, and values computed inside a cell follow the cell’s field. An embedded Facet with fields or pairs defaults to layout="grid". Every cell shows the same observations, so selection, hover and brushing work by observation across cells and connect(facet.endpoint("values")) needs no key. A Facet split by a Fold’s key still works and gives the same cells. The grid has one legend: cells add their marks to it, and legend (true or {position}) shows the automatic legend around the grid. legend="cell" restores one legend per cell.