Public
Edited
May 12, 2023
2 forks
2 stars
Insert cell
Insert cell
Plot.plot({
x: {
grid: true,
label: "Population (%) →",
percent: true
},
y: {
domain: stateage.ages, // in age order
reverse: true,
label: "↑ Age (years)",
labelAnchor: "top"
},
marks: [
Plot.ruleX([0]),
Plot.tickX(stateage, Plot.normalizeX("sum", {z: "state", x: "population", y: "age"}))
]
})
Insert cell
wide = FileAttachment("us-population-state-age.csv").csv({ typed: true })
Insert cell
stateage = {
const ages = wide.columns.slice(1);
const values = wide.flatMap(({name, ...values}) => ages.map((age) => ({state: name, age, population: values[age]})));
values.ages = ages;
return values;
}
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