Plot.plot({
height: 780,
marginLeft: 100,
grid: true,
x: {
axis: "top",
round: true,
label: "← decrease · Change in population, 2010–2019 (%) · increase →",
labelAnchor: "center",
tickFormat: "+",
transform: d => d * 100
},
y: {
label: null,
domain: d3.sort(popchange, d => (d[2010] - d[2019]) / d[2010]).map(d => d.State)
},
color: {
range: ["#e15759", "#4e79a7"]
},
marks: [
Plot.barX(popchange, {
y: "State",
x: d => (d[2019] - d[2010]) / d[2010],
fill: d => Math.sign(d[2019] - d[2010])
}),
Plot.ruleX([0])
]
})