function Matrix(data, {
width = 640,
top = 20
} = {}) {
return Plot.plot({
marks: [
Plot.cell(data, {
x: "item_a",
y: "item_b",
fill: "count",
stroke: "gray",
title: d => `${d.item_a} + ${d.item_b} = ${d.count}`,
sort: { y: "fill", x: "fill", reverse: true, limit: top }
}),
width > 750 && top < 30 ? Plot.text(data, colorContrast({
x: "item_a",
y: "item_b",
text: "count",
fill: "count",
title: d => `${d.item_a} + ${d.item_b} = ${d.count}`,
})) : null
],
x: { tickRotate: 90, label: null},
y: { label: null },
color: { scheme: "greens"},
marginLeft: 250,
marginRight: 100,
marginBottom: 200,
grid: true,
width: width
})
}