Published unlisted
Edited
Jan 20, 2022
Insert cell
Insert cell
Plot.dot(data, {
x: "flipper_length",
y: "body_mass",
fill: "species",
title: "species",
layouts
}).plot({ grid: true })
Insert cell
Insert cell
Plot.dot(data, {
x: "flipper_length",
y: "body_mass",
fill: "species",
title: "species",
layouts
}).plot({ facet: { data, x: "island" }, grid: true })
Insert cell
Plot.dot(data, {
x: "flipper_length",
y: "body_mass",
fill: "species",
title: "species",
layouts: [layoutCollide]
}).plot({ facet: { data, x: "island" }, grid: true })
Insert cell
function layoutDarker(values) {
for (let i = 0; i < values.fill.length; i++)
values.fill[i] = d3.rgb(values.fill[i]).darker();
return () => {};
}
Insert cell
function layoutCollide({ x: X, y: Y, r: R }) {
return (index) => {
const nodes = Array.from(index, (i) => ({
i,
x: X[i],
y: Y[i],
r: R ? R[i] : 4
}));
const simulation = d3
.forceSimulation()
.force(
"x",
d3.forceX(({ x }) => x)
)
.force(
"y",
d3.forceY(({ y }) => y)
)
.force(
"collide",
d3.forceCollide(({ r }) => 1 + r)
);
simulation.nodes(nodes).tick(30).stop();
for (const node of nodes) (X[node.i] = node.x), (Y[node.i] = node.y);
};
}
Insert cell
import { data } from "@observablehq/plot-exploration-penguins"
Insert cell
Plot = FileAttachment("plot.umd.js").url().then(require)
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