Plot.plot({
height: 350,
marginLeft: 80,
x: { domain: [0, 200] },
color: { domain: Plot.valueof(penguins, "sex"), legend: true },
fy: { axis: null },
marks: [
Plot.gridX(),
Plot.text(["island", "species", "sex"], {
frameAnchor: "middle",
text: Plot.identity,
fy: Plot.identity,
render([i], { scales }, { channels }, dimensions) {
return svg`<g>${Plot.barX(
penguins,
Plot.groupY(
{ x: "count" },
{ y: channels.text.value[i], fill: "sex" }
)
).plot({
...dimensions,
...scales,
x: { ...scales.x, axis: null }
})}`;
}
})
]
})