Public
Edited
May 15, 2023
Insert cell
Insert cell
Plot.plot({
label: null,
x: {
axis: "top",
label: "← decrease · Change in population, 2010–2019 (%) · increase →",
labelAnchor: "center",
tickFormat: "+",
percent: true
},
color: {
scheme: "PiYg",
type: "ordinal"
},
marks: [
Plot.barX(statepop, {y: "State", x: (d) => (d[2019] - d[2010]) / d[2010], fill: (d) => Math.sign(d[2019] - d[2010]), sort: {y: "x"}}),
Plot.gridX({stroke: "white", strokeOpacity: 0.5}),
Plot.axisY({x: 0}),
Plot.ruleX([0])
]
})
Insert cell
statepop = FileAttachment("us-state-population-2010-2019.csv").csv({typed: true})
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