Plot.plot({
height: 500,
grid: true,
insetLeft: 60,
insetBottom: 60,
marks: [
Plot.spike(faithful, {
x: (d, i) => d["waiting"] + jitter[2 * i],
frameAnchor: "bottom",
opacity: 0.2,
stroke: "steelblue"
}),
Plot.spike(faithful, {
y: (d, i) => d["eruptions"] + jitter[2 * i + 1] / 60,
frameAnchor: "left",
opacity: 0.2,
stroke: null,
fill: "orangered",
rotate: 90
}),
Plot.density(faithful, { x: "waiting", y: "eruptions" }),
Plot.dot(faithful, {
x: (d, i) => d["waiting"] + jitter[2 * i],
y: (d, i) => d["eruptions"] + jitter[2 * i + 1] / 60,
r: 2,
fill: "currentColor"
})
]
})