Plot.plot({
marks: [
Plot.frame(),
Plot.dot(worldbank, {
filter: (d) => d.year == 2010,
x: "gdp",
y: "co2",
fill: "life_exp",
r: "life_exp",
opacity: 0.7,
tip: true,
fy: "income_group"
})
],
x: { type: "log", label: "GDP (USD)" },
y: { type: "log", label: "CO2 Emissions" },
fy: {
label: "Income group",
domain: [
"NA",
"Low income",
"Lower middle income",
"Upper middle income",
"High income"
],
reverse: true
},
color: { legend: true, label: "Life expectancy (years)", scheme: "BuPu" },
r: { domain: d3.extent(worldbank, (d) => d.life_exp), range: [1, 10] },
marginRight: 150
})