Public
Edited
Jan 10, 2024
Insert cell
Insert cell
Insert cell
Insert cell
anim = {
let N = 1000;
let dx = 1 / N;
let pts = d3
.range(0, 1, dx / 2)
.map((x) => [x, Math.cos(n * global.t) * Math.sin(Math.PI * n * x)]);

while (run) {
await Promises.delay(20);
global.t = global.t + 0.05;
pts = d3
.range(0, 1, dx / 2)
.map((x) => [x, Math.cos(n * global.t) * Math.sin(Math.PI * n * x)]);
yield Plot.plot({
y: { domain: [-1.1, 1.1] },
marks: [
Plot.line(pts),
Plot.axisX({ y: 0 }),
Plot.ruleX([0]),
Plot.ruleY([0])
]
});
}
yield Plot.plot({
y: { domain: [-1.1, 1.1] },
marks: [
Plot.line(pts),
Plot.axisX({ y: 0 }),
Plot.ruleX([0]),
Plot.ruleY([0])
]
});
}
Insert cell
global = ({ t: 0 })
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