Plot.plot({
marks: [
Plot.lineY(stocks, { x: "Date", y: "Close", stroke: "symbol", opacity: 0.3 }),
Plot.lineY(
stocks,
Plot.windowY({ k: 20, anchor: "middle", reduce: "mean" }, { x: "Date", y: "Close", stroke: "symbol" })
),
Plot.text(stocks, Plot.selectLast(Plot.windowY({k: 20}, {x: "Date", y: "Close", text: "symbol", fill: "symbol", dx: 10})))
],
color: { legend: true }
})