Public
Edited
Jun 8, 2023
2 forks
17 stars
Insert cell
Insert cell
Plot.plot({
color: {
legend: true,
type: "quantize",
scheme: "spectral",
n: 10,
label: "percentile"
},
y: {label: "density"},
marks: [
Plot.rectY(numbers, {
fill: (d, i) => i,
...Plot.binX({
y: (bin, {x1, x2}) => 1 / (x2 - x1),
thresholds: percentiles
})
}),
Plot.ruleY([0])
]
})
Insert cell
numbers = Float64Array.from({length: 10000}, d3.randomNormal.source(d3.randomLcg(3))())
Insert cell
function percentiles(numbers) {
const sorted = d3.sort(numbers);
return d3.range(0, 101).map((q) => d3.quantileSorted(sorted, q / 100));
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more