Public
Edited
May 2, 2023
Insert cell
Insert cell
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barY(alphabet, {
x: "letter",
y: "frequency",
title: (b) => `${b.letter}: ${(b.frequency * 100).toFixed(2)}%`, //title: "frequency",
sort: { x: "y", reverse: true }
}),
Plot.ruleY([0])
]
})
Insert cell
Insert cell
//selectedAthletes = olympians.filter((d) => d.nationality === "BRA")

//viewof selectedAthletes = Inputs.select(
// d3.group(olympians, (d) => d.nationality),
// { label: "Nationality:" }
//)

viewof selectedAthletes = Inputs.select(
d3.group(olympians, (d) => d.sport),
{ label: "Sport:" }
)
Insert cell
Plot.plot({
marks: [
Plot.rectY(
selectedAthletes,
Plot.binX({ y: "count" }, { x: "weight", fill: "sex" })
),
Plot.ruleY([0])
],
color: {
legend: true
}
})
Insert cell
Insert cell
Insert cell
alphaFiltered = alphabet.filter((d) => d.frequency >= minFrequency)
Insert cell
Plot.plot({
marks: [
Plot.barY(alphaFiltered, { x: "letter", y: "frequency" }),
Plot.ruleY([0])
],
x: {
domain: d3.sort(alphabet.map((d) => d.letter)) //Pin
}
})
Insert cell
Insert cell
viewof minFrequency2 = Inputs.range([0, 0.13], {
label: "Min Frequency 2",
step: 0.01,
value: 0
})
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0, minFrequency2], { stroke: "orange" }),
Plot.barY(alphaFiltered, {
x: "letter",
y: "frequency",
fill: (d) => (d.frequency >= minFrequency2 ? "orange" : "lightgray")
})
],
x: {
domain: d3.sort(alphabet.map((d) => d.letter)) //Pin
}
})
Insert cell
Insert cell
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