Plot.plot({
subtitle: "Do you feel old?",
marginLeft: 70,
x: { label: null, tickFormat: ".0%" },
y: { label: "Age" },
marks: [
Plot.barX(data1, { x: "frac", y: "age", fill: (d) => d.feel === "Yes" }),
Plot.textX(
data1,
Plot.selectFirst(
Plot.stackX({
x: "frac",
y: "age",
z: (d) => d.feel === "Yes",
text: "feel",
inset: 0.5,
fill: "black",
stroke: "white"
})
)
)
]
})