Plot.plot({
aspectRatio: 1,
marks: [
Plot.line(P.X, {
x: P.X,
y: P.Y,
stroke: (d, i) => Math.floor(i / 1000),
tip: true,
render: (index, scales, values, dimensions, context, next) => {
const ctx = DOM.context2d(dimensions.width, dimensions.height);
let c;
ctx.globalAlpha = 0.05;
for (const i of index) {
if (values.stroke[i] !== c) {
ctx.stroke();
ctx.beginPath();
ctx.strokeStyle = c = values.stroke[i];
ctx.moveTo(values.x[i], values.y[i]);
}
ctx.lineTo(values.x[i], values.y[i]);
}
return svg`<foreignObject width=${dimensions.width} height=${dimensions.height}>${ctx.canvas}`;
}
})
]
})