Public
Edited
Sep 9, 2024
14 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.dot(
{ length },
{
...Plot.group(
{ r: "count" },
{ x, y, fill: "brown", stroke: "white", strokeWidth: 0.75 }
),
sort: sort ? ({ length }) => length : false,
reverse
}
).plot({ width: 400, height: 400, grid: true })
Insert cell
Insert cell
Insert cell
Insert cell
Plot.dot(
{ length },
{
...Plot.bin(
{
data: (d) => d.length,
r: "count",
thresholds: 14
},
{ x: xn, y: yn, stroke: "white", strokeWidth: 0.75, fill: "steelblue" }
),
sort: sort2 ? (d) => d : false,
reverse: reverse2
}
).plot({
width: 400,
height: 400,
x: { ticks: 10, inset: 15 },
y: { ticks: 10, inset: 15 },
grid: true
})
Insert cell
Insert cell
Insert cell
Plot.plot({
width: 400,
height: 250,
marks: [
Plot.rectY(
data,
Plot.stackY(
Plot.binX(
{ y: "count", thresholds: 7, sort: "first", title: "first" },
{
x: "value",
text: "abbr",
sort: "value",
fill: "value",
title: (d) => `${d.abbr} (${d.value})`,
stroke: "white"
}
)
)
),
Plot.text(
data,
Plot.stackY(
Plot.binX(
{
y: "count",
thresholds: 7,
sort: "first",
text: "first",
title: "first"
},
{
x: "value",
sort: "value",
z: "abbr",
text: "abbr",
fill: "black",
title: (d) => `${d.abbr} (${d.value})`
}
)
)
),
Plot.ruleX([0]),
Plot.ruleY([0])
],
color: { type: "diverging", pivot: 3 },
x: { ticks: 7 }
})
Insert cell
Insert cell
Plot.dot(
cars,
Plot.reverse(
Plot.sort(
"length",
Plot.binY(
{ r: "count" },
{
x: "year",
y: "economy (mpg)",
fill: "cylinders",
thresholds: 20
}
)
)
)
).plot()
Insert cell
Insert cell
length = 10000
Insert cell
xn = Plot.valueof({ length }, d3.randomBinomial(10, 0.5)).map(
(d) => d - Math.random()
) // numbers, for binning
Insert cell
x = xn.map((i) => String.fromCharCode(65 + Math.round(i))) // strings, for grouping
Insert cell
yn = Plot.valueof({ length }, d3.randomBinomial(10, 0.5)).map(
(d) => d - Math.random()
)
Insert cell
y = yn.map((i) => String.fromCharCode(65 + Math.round(i)))
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