Public
Edited
Jul 22, 2024
Insert cell
Insert cell
Insert cell
// Plot.binX() returns an object with has a transform method, any unconsumed options that you give it, and other stuff.
Plot.binX({y: "count"}, {x: "weight", checkitout: "Hello, world!"})
Insert cell
// The facets array for the case of no faceting is just an array of the array indices.
facets = [Array.from(Array(olympians.length).keys())]
Insert cell
// .transform(data, facets) returns an object with data and facets that containing arrays of binned data and a new facets array
Plot.binX({y: "count"}, {x: "weight"}).transform(olympians, facets)
Insert cell
Insert cell
d3bins = d3.bin().thresholds(80).value((d) => d.weight)(olympians)
Insert cell
Plot.rectY(d3bins, {x1: "x0", x2: "x1", y2: "length"}).plot({x: {round: true}, y: {grid: true}})
Insert cell
Plot.plot({
x: {round: true},
y: {grid: true, label: `whatever`},
tip: true,
marks: [
Plot.rectY(olympians, Plot.binX({y: "sum", title: "count"}, {x: "weight", y: "weight", inset: 0})),
Plot.ruleY([0])
]
})
Insert cell
Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight", inset: 0, tip: true})).initialize()
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more