Public
Edited
Nov 23, 2023
Insert cell
Insert cell
quantilesScale = d3.scaleThreshold(
[2, 5, 10],
[[], [0.25, 0.5, 0.75], [0.25, 0.5, 0.75], [0.25, 0.5, 0.75, 0.95, 0.99]]
)
Insert cell
// 2 5 10
// [] | [0.25, 0.5, 0.75] | [0.25, 0.5, 0.75] | [0.25, 0.5, 0.75, 0.95, 0.99]
// [1, 4.5, ]
Insert cell
quantilesScale(11)
Insert cell
[0.25, 0.5, 0.75].map((d) => d3.quantile([1, 2, 3], d))
Insert cell
d3.range(1, 100)
Insert cell
d3.mean(d3.range(1, 100))
Insert cell
[0.25, 0.5, 0.75, 0.9, 0.95].map((d) => d3.quantile(d3.range(1, 100), d))
Insert cell
[0.25, 0.5, 0.75].map((d) => d3.quantile([0, 0, 0, 0, 0, 0, 2, 3], d))
Insert cell
Insert cell
// data = d3.range(10)
// data = [1, 2]
data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2]
// data = [0.1, 0.1, 0.1, 0.1, 0.1, 1, 1, 10]
Insert cell
// colorScaleFn([1,2,5,10][[], [25], [25, 50, 75], ...])
// colorScaleFn([1,2,5,10][0, 2, 3, 6])

// function colorScale() {
// // d3.quantile()
// // simple.ckmeans(data, 2)
// // d3.pairs(bins).map(([a, b]) => (d3.max(a) + d3.min(b)) / 2);
// if 0:
// colors = ['blue', 'blue']
// if 2:
// colors = ['blue', 'red']
// }


Insert cell
d3.pairs(bins)
Insert cell
// [0,1,2,3,4] 4.5 [5,6,7,8,9]
bins = simple.ckmeans(data, 3)
Insert cell
nClusters = d3.scaleThreshold([2, 5, 10], [0, 2, 4, 6])
Insert cell
nClusters(100000)
Insert cell
d3.pairs(bins).map(([a, b]) => (d3.max(a) + d3.min(b)) / 2);
Insert cell
Insert cell
simple = import("simple-statistics@7")
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