Plot.plot({
width: 960,
height: 480,
fx: { domain: ["D", "E", "F"] },
color: { legend: "ramp", domain: ["IF", "SI1", "I1"] },
y: { domain: [51, 71.9], insetTop: 20, labelAnchor: "center" },
marginLeft: 40,
marginBottom: 40,
marginTop: 35,
marks: [
Plot.axisFx({ anchor: "top" }),
Plot.frame({ anchor: "top", strokeOpacity: 1 }),
Plot.dot(diamonds, {
fx: "color",
y: "depth",
fill: "clarity",
render(index, { scales }, _values, { facet, ...dimensions }) {
const data = Array.from(index, (i) => this.data[i]);
const plot = Plot.plot({
...dimensions,
marginTop: 60,
...scales,
fx: {
axis: "bottom",
paddingOuter: 0.1,
paddingInner: 0.2,
label: index.fi ? null : undefined
},
x: {
domain: scales.color.domain,
axis: "top",
labelAnchor: "left",
labelOffset: 16,
...(index.fi && { label: null }),
grid: true,
tickSize: 0
},
y: { ...scales.y, grid: 4, axis: null },
marks: [
Plot.frame({ anchor: "bottom" }),
Plot.boxY(data, {
fx: "cut",
x: "clarity",
y: "depth",
fill: "clarity"
})
]
});
return svg`<g>${plot}`;
}
})
]
})