Public
Edited
Jun 5, 2023
2 forks
Insert cell
Insert cell
Plot.plot({
width: 928,
height: 832,
x: {axis: "top", tickFormat: "%"},
y: {label: null},
color: {scheme: "Spectral", legend: "ramp", width: 340, label: "Age (years)"},
marks: [
Plot.barX(tidy, {
x: "population",
y: "state",
fill: "age",
offset: "normalize",
sort: {color: null, y: "-x", reduce: "first"}
}),
Plot.ruleX([0])
]
})
Insert cell
population = FileAttachment("us-population-state-age.csv").csv({typed: true})
Insert cell
Insert cell
tidy = population.columns.slice(1).flatMap((age) => population.map(d => ({state: d.name, age, population: d[age]})))
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