Published
Edited
Apr 4, 2022
1 fork
37 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barX(
penguins,
Plot.binX(
{ fill: "mean" },
{
x: "body_mass",
fill: "body_mass",
thresholds: (values) => {
const bins = simple.ckmeans(
values.filter((d) => d == +d),
thresholds
);
return d3.pairs(bins).map(([a, b]) => (d3.max(a) + d3.min(b)) / 2);
}
}
)
),
Plot.textX(
penguins,
Plot.binX(
{ text: "count" },
{
x: "body_mass",
thresholds: (values) => {
const bins = simple.ckmeans(
values.filter((d) => d == +d),
thresholds
);
return d3.pairs(bins).map(([a, b]) => (d3.max(a) + d3.min(b)) / 2);
},
fill: "white"
}
)
)
],
color: { scheme: "viridis", domain: [2700, 6000] },
width
})
Insert cell
Insert cell
simple = import("simple-statistics@7")
Insert cell
penguins = FileAttachment("palmer-penguins.csv").csv({ typed: true })
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