normalized_histogram = Plot.plot({
marks: [
Plot.rectY(
pts,
Plot.binX(
{
y: (a, bin) => {
return a.length / pts.length / (bin.x2 - bin.x1);
}
},
{ fill: "gray" }
)
),
Plot.line(
d3.range(-4, 4, 0.02).map((x) => [x, f(x)]),
{ stroke: "#B00", strokeWidth: 4 }
),
Plot.ruleX([0]),
Plot.ruleY([0])
]
})