Plot.plot({
y: {
domain: [15, 87],
ticks: 7,
grid: true,
label: "↑ temperature (°F)"
},
x: {
inset: 4
},
marks: [
differenceY(data, {x: "date", y1: "San Francisco", y2: "New York", curve: "step", fill: orange}),
differenceY(data, {x: "date", y1: "New York", y2: "San Francisco", curve: "step", fill: blue}),
Plot.line(data, {x: "date", y: "New York", curve: "step"}),
Plot.text(data, Plot.selectMaxY({
x: "date",
y: "New York",
text: () => "New York",
dy: -5
})),
Plot.text(data, {
...Plot.selectMinY({
x: "date",
y: d => d["San Francisco"] - d["New York"]
}),
y: "San Francisco",
text: () => "San Francisco",
dy: 10
}),
Plot.text(data, Plot.selectMinY({
x: "date",
y: "New York",
text: () => "New York",
dy: 10
})),
Plot.text(data, {
...Plot.selectMaxY({
x: "date",
y: d => d["San Francisco"] - d["New York"],
text: () => "San Francisco"
}),
y: "San Francisco",
dy: -20
}),
],
width,
height: 450
})