Published
Edited
Apr 4, 2022
1 fork
7 stars
Insert cell
Insert cell
data = FileAttachment("trials.json").json()
Insert cell
Plot.plot({
x: {
nice: true,
ticks: 20,
tickFormat: (d) =>
d === Math.floor(d) ? d3.format("~s")(Math.pow(10, d)) : "•",
label: "sample size (log scale) →"
},
marks: [
Plot.rectY(
data,
Plot.binX(
{
y: "count",
title
},
{
x: (d) => Math.log10(d || NaN),
fill: "orange"
}
)
),
Plot.tickY([0])
]
})
Insert cell
Insert cell
d3.range(0.6, 6.2, 0.2).map((tick) => Math.floor(Math.pow(10, tick)))
Insert cell
Insert cell
Plot.plot({
x: {
ticks: 12,
transform: (d) => Math.pow(10, d),
type: "log",
tickFormat: "~s",
label: "sample size (log scale) →"
},
marks: [
Plot.rectY(
data,
Plot.binX(
{ y: "count" },
{
x: (d) => Math.log10(d || NaN)
}
)
)
]
})
Insert cell
// a brave function that takes a sample value and returns the interval that contains it
title = ([d]) => {
const lo = Math.pow(10, Math.floor(Math.log10(d) * 5) / 5);
const hi = Math.pow(10, (1 + Math.floor(Math.log10(d) * 5)) / 5);
return `[${Math.floor(lo)}-${Math.floor(hi - 1)}]`;
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more