mychart2 = Plot.plot({
y: {label: "Per Capita Power (watts)"},
x: {label: "Population (million)"},
marks: [
Plot.rectY(groupdata20221, Plot.stackX(
{x: "Population", y2: "PerCapPower", fill: "Region",
title: (d) => `${d.Region} ${d.str}`
})),
Plot.text(groupdata20221,{
Plot.stackX({x: "Population"}),
y: "PerCapPower",
textAnchor: "middle",
dy: -5,
text:(d) => `${d.PerCapPower.toFixed(2)}`
}),
Plot.text([[4000,800]], {textAnchor: "start",
text: d=>[`Total current global power 2022: ${global} GW\n
IEA NetZero by 2050 target: ${global *2.6} GW`]})
]
})