plot = (interval, level, counts, quantize, domain, ghost, caption, legend) =>
Plot.plot({
marks: [
Plot.rectY(
quantizedBinRanges(level),
Plot.normalizeY("max", {
x1: (d) => d[0],
x2: (d, i, a) => d[1] + 1,
y: (d, i) => ghost[i],
fill: () => "Full dataset",
inset: 0.5
})
),
Plot.rectY(
quantizedBinRanges(level),
Plot.normalizeY("max", {
x1: (d) => d[0],
x2: (d, i, a) => d[1] + 1,
y: (d, i) => counts[i],
fill: () => "Filtered dataset",
inset: 0.5
})
),
Plot.rectY([interval], {
x1: (d) => d[0],
x2: (d) => d[1] + 1,
y0: null,
y1: null,
fill: "#748FDE",
fillOpacity: 0.15,
stroke: "#748FDE",
strokeOpacity: 0.5,
insetTop: -7
}),
Plot.ruleY([0])
],
height,
color: {
legend,
domain: ["Filtered dataset", "Full dataset"],
range: ["#000", "#DDD8D4"]
},
x: { transform: quantize.invert },
y: { percent: true, tickFormat: "s", label: "% of dataset" },
caption
})