updatePlot(year) {
const yearData = data.filter(d => d.year === year);
ratio = new Map(yearData.map(d => [d.state, +d.black_to_white_incarceration_ratio]));
Plot.plot({
width: 975,
height: 610,
projection: "albers-usa",
color: {
type: "quantize",
n: 9,
domain: [0, 4],
scheme: "Reds",
label: "Ratio",
legend: true
},
marks: [
Plot.geo(states, Plot.centroid({
fill: d => ratio.get(d.properties.name),
tip: true,
channels: {
County: d => d.properties.name,
State: d => statemap.get(d.id.slice(0,2)).properties.name
}
})),
Plot.geo(states, {stroke: "#e2e2e2"})
]
})