xMarket = netY / tS
xEff = Math.max((netY - v) / (tS + e), 0)
excess = xMarket - xEff
area = r => Math.PI * r * r
xmaxS = xMarket * 1.2
rowsS = d3.range(0, xmaxS, xmaxS / 200)
Plot.plot({
height: 340, marginLeft: 70,
x: {label: "Distance from the CBD (miles) →", domain: [0, xmaxS]},
y: {label: "↑ Value of land in urban use, above farm rent ($)", grid: true},
color: {legend: true, domain: ["Private value (what developers see)", "Social value (counts congestion)", "Open-space value v"], range: ["#2b6cb0", "#881124", "#4a7c3a"]},
marks: [
Plot.ruleY([0]),
Plot.line(rowsS, {x: d => d, y: d => netY - tS * d, stroke: () => "Private value (what developers see)", strokeWidth: 2}),
Plot.line(rowsS, {x: d => d, y: d => netY - (tS + e) * d, stroke: () => "Social value (counts congestion)", strokeWidth: 2}),
Plot.ruleY([v], {stroke: "#4a7c3a", strokeWidth: 2, strokeDasharray: "5,4"}),
Plot.ruleX([xMarket], {stroke: "#2b6cb0", strokeOpacity: 0.5}),
Plot.ruleX([xEff], {stroke: "#881124", strokeOpacity: 0.5}),
Plot.text([{x: xMarket}], {x: "x", y: netY * 0.9, text: () => "market edge", textAnchor: "end", dx: -4}),
Plot.text([{x: xEff}], {x: "x", y: netY * 0.8, text: () => "efficient edge", textAnchor: "end", dx: -4})
]
})