Plot.plot({
x: { domain: [-3.5, 8.5] },
y: { domain: [0, 0.45], grid: true },
marks: [
Plot.areaY(
pts,
Plot.mapY(
(counts) => counts.map((d) => d / d3.sum(counts) / interval),
Plot.binX(
{ y2: "count" },
{
x: "value",
fy: "mu",
fill: "series",
fillOpacity: 0.5,
interval,
curve: "basis"
}
)
)
),
Plot.lineY(
pts,
Plot.mapY(
(counts) => counts.map((d) => d / d3.sum(counts) / interval),
Plot.binX(
{ y: "count" },
{ x: "value", fy: "mu", stroke: "series", interval, curve: "basis" }
)
)
)
]
})