Plot.plot({
x: {
label: null,
type: "point",
tickFormat: (d) => d3.timeFormat("%b")(new Date(2000, d-1, 1)),
},
y: {
grid: true,
label: "↑ Precipitation (inches)"
},
marks: [
Plot.ruleY([0]),
Plot.line(data, {
...xyz,
stroke: "LightGray",
}),
Plot.line(data.filter(({ Year }) => Year === 2022), {
...xyz,
stroke: "black",
strokeWidth: 2,
}),
Plot.text(data.filter(({ Year }) => Year === 2022), Plot.selectLast({
...xyz,
...label,
fill: "black",
fontWeight: 600,
})),
Plot.line(stats, {
x: "Month",
y: "Median",
stroke: "#9e6b90",
}),
Plot.text(stats, Plot.selectLast({
x: "Month",
y: "Median",
...label,
text: (d) => "Median",
fill: "#9e6b90",
})),
Plot.line(wettest, {
...xyz,
stroke: "#714dbf",
}),
Plot.text(wettest, Plot.selectLast({
...xyz,
...label,
fill: "#714dbf",
})),
Plot.line(driest, {
...xyz,
stroke: "#cf9270",
}),
Plot.text(driest, Plot.selectLast({
...xyz,
...label,
fill: "#cf9270",
})),
]
})