cell = Plot.plot({
projection: "albers-usa",
color: { legend: true, scheme: "viridis" },
grid: true,
height: 700,
width: 900,
marginLeft: 70,
x: { nice: true },
y: { inset: 5 },
facet: { data: filteredData, y: "year" },
marks: [
Plot.geo(states),
Plot.density(filteredData, {
x: "longitude",
y: "latitude",
bandwidth: 15,
fill: "density",
opacity: 0.15
}),
Plot.dot(filteredData, {
x: "longitude",
y: "latitude",
fill: "black",
r: 1.5
}),
Plot.text(
states.features,
Plot.centroid({
text: (d) => d.properties.name,
fill: "currentColor",
dy: 40,
filter: (d) => d.properties.name.match(/^Louis/)
})
),
Plot.text(text_data, {
x: -100,
y: 45,
text: (d) => `Year: ${d.year}\nSlope: ${d3.format(".2f")(d.b0)}`,
dy: 10,
fy: "year",
fill: "black",
stroke: "white"
}),
Plot.linearRegressionY(filteredData, {
x: "longitude",
y: "value",
stroke: "red",
ci: 0,
opacity: 0.2
})
]
})