Public
Edited
Mar 4, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function markPointInterval(data, {y, x, fill, text, fillText}){
const marks = [
//range
Plot.ruleY(data,
Plot.groupY({x1: "min", x2: "max"},
{y: y, x: x, stroke: fill, strokeWidth:2})
),
//quartiles IQR
Plot.ruleY(data,
Plot.groupY({x1: (D) => d3.quantile(D, 0.25),x2: (D) => d3.quantile(D, 0.75)},
{y: y, x: x, stroke: fill, strokeWidth:4.5})),
//median dot
Plot.dot(data,
Plot.groupY({x: "median"},
{y: y, x: x, fill: fill, r:9})),
//median text
Plot.text(data,
Plot.groupY({x: "median", text: d=> d3.median(d).toFixed(0)},
{y: y, x: x, fill: fillText, text: text,
fontSize:8})),
]

return marks
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
olympians
Insert cell
Insert cell
Insert cell
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