legend = Plot.plot({
color: {
range: scheme,
transform: ([a, b]) => 3 * a + b,
unknown: "#ccc"
},
axis: null,
margin: 0,
inset: 18,
width: 106,
height: 106,
style: "overflow: visible;",
marks: [
Plot.dot(d3.cross([0, 1, 2], [0, 1, 2]), {
x: ([a, b]) => b - a,
y: ([a, b]) => b + a,
symbol: "square",
rotate: 45,
r: 14,
fill: (d) => d,
title: ([a, b]) => `ASOL${label(a)}\nASAN${label(b)}`,
tip: true
}),
Plot.text(["ASAN →"], {
frameAnchor: "right",
fontWeight: "bold",
rotate: -45,
dx: -12,
dy: 22
}),
Plot.text(["← ASOL"], {
frameAnchor: "left",
fontWeight: "bold",
rotate: 45,
dx: 12,
dy: 22
})
]
})