Plot.plot({
x: { label: "Body mass (g)" },
y: { label: "Flipper length (mm)" },
color: { legend: true },
width: 800,
caption:
"Penguin body mass and flipper length for three species (Adélie, chinstrap and gentoo) at three islands (Biscoe, Dream and Torgersen) near Palmer Archipelago, Antarctica. Data: Gorman et al. 2014.",
insetTop: 20,
insetLeft: 20,
insetRight: 20,
insetBottom: 20,
marks: [
Plot.frame({ strokeOpacity: 0.1 }),
Plot.rectX(
await FileAttachment("penguins.csv").csv({ typed: "auto" }),
Plot.binY(
{ x: "distinct" },
{
fx: "island",
x: "species",
y: "flipper_length_mm",
fill: "flipper_length_mm",
tip: true
}
)
),
Plot.ruleX([0])
]
})