Public
Edited
Sep 4, 2023
Insert cell
Insert cell
data = FileAttachment("penguins.csv").csv({ typed: true })
Insert cell
Insert cell
attributes = [
"culmen_length_mm",
"culmen_depth_mm",
"flipper_length_mm",
"body_mass_g"
]
Insert cell
Insert cell
Plot.rectY(data, Plot.binX({ y: "count" }, { x: "body_mass_g" })).plot({
width: 300,
height: 100
})
Insert cell
Insert cell
htl.html`${attributes.map((name) =>
Plot.rectY(data, Plot.binX({ y: "count" }, { x: name })).plot({
width: 300,
height: 100
})
)}`
Insert cell
Insert cell
htl.html`<div style="
display: grid;
grid-gap: 1.75em;
grid-template-columns: repeat(2, 3fr);
">${attributes.map((name) =>
Plot.rectY(data, Plot.binX({ y: "count" }, { x: name })).plot({
width: 450,
height: 250
})
)}</div>`
Insert cell
Insert cell
Insert cell
htl.svg`<svg height=${attributes.length * height}>${attributes.map((name, i) =>
htl.svg`<g transform="translate(0, ${height * i})">
${Plot.rectY(data, Plot.binX({ y: "count" }, { x: name })).plot({
width: 300,
height
})}
</g>`
)}</svg>`
Insert cell
height = 100
Insert cell
Insert cell
import { tweet } from "@mbostock/tweet"
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