Plot.plot({
inset: 20,
marginLeft: 140,
width: 700,
height: 400,
y: {
domain: top10Affordability.map(d => d.Country).reverse(),
tickSize: 0,
label: null
},
x: {
label: "Affordability Score (Purchasing Power ÷ Price/Income)",
grid: true
},
marks: [
Plot.ruleX(top10Affordability, {
x1: 0,
x2: "affordability",
y: "Country",
stroke: "#bbb",
strokeWidth: 2
}),
Plot.dot(top10Affordability, {
x: "affordability",
y: "Country",
fill: "#1f77b4",
r: 7,
title: d => `
Country: ${d.Country}
Affordability: ${d.affordability.toFixed(2)}`
}),
Plot.text(top10Affordability, {
x: "affordability",
y: "Country",
text: d => d.affordability.toFixed(2),
dx: 10,
dy: 2,
fontSize: 11,
fill: "#333"
})
]
});