plot.ts aktualisiert

main
Alexander Kimmig 2025-06-03 00:09:34 +02:00
parent 715a3d0f4d
commit 031f151f56
1 changed files with 6 additions and 0 deletions

View File

@ -6,4 +6,10 @@ export const document = new DOMParser().parseFromString(
export const plot = (data) => {
return Plot.line(data, {x: "x", y: "y"}).plot({y: {grid: true}, document})
}
export const plotxy = (xmin, xmax, step, y) => {
const x = Array.from({length: (xmax - xmin)/step}, (_, i) => (i - xmin) * step)
const data = x.map(x => ({x, y: y(x)}))
return Plot.line(data, {x: "x", y: "y"}).plot({y: {grid: true}, document})
}