Unlisted
Edited
Mar 7, 2024
Insert cell
Insert cell
data = FileAttachment("penguins.csv").csv({typed: true})
Insert cell
Insert cell
Plot.plot({
y: {grid: true},
color: {
legend: true,
// domain: ["MALE", "FEMALE", null],
// range: ["var(--male)", "var(--female)", "black"]
},
marks: [
Plot.rectY(data2, Plot.binX({y: "count"}, {x: "flipper_length_mm", fill: "test"})),
Plot.ruleY([0])
]
})
Insert cell
data2 = data.map((dd) => {
let other;
if (dd.sex == "MALE") {
other = "var(--male)";
} else if (dd.sex == "FEMALE") {
other = "var(--female)"
} else {
other = "var()"
}
return {...dd, test: other}
})
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more