Plot.plot({
width: width,
inset: 12,
x: {
label: "Width (cm)",
domain: [0, 200]
},
y: {
label: "Height (cm)",
domain: [0, 200]
},
facet: {
data: data,
y: (d) => Math.floor(categories.indexOf(d.category) / cols),
x: (d) => categories.indexOf(d.category) % cols
},
fy: {
tickFormat: null
},
fx: {
tickFormat: null
},
marks: [
Plot.rect(data, {
filter: (d) => d.width < 200 && d.height < 200,
opacity: 0.1,
x1: 0,
x2: "width",
y1: 0,
y2: "height",
strokeWidth: 4,
fill: "#FFDA1A",
stroke: "#0051BA"
}),
Plot.text(
data,
Plot.selectLast({
text: "category",
textAnchor: "start",
fontWeight: "bold",
x: () => 0,
y: () => 0,
dy: 10
})
)
]
})