-
What's the best way to plot a continuous function? The documentation of Plot seems to use only sets of discrete values. Do I need to manually select the discrete set of values in the domain and compute the range? What step size is optimal for Plot? Or can I provide the function to plot such that it doesn't need to interpolate between my discrete set of values? For example, here's a function const f = (x) => x * x;
const data = d3
.range(0, 3, 0.01)
.map((x) => ({ x, y: f(x) }));
Plot.plot({
marks: [
Plot.line(data, { x: "x", y: "y" }),
],
}); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Plot has no special affordances for plotting functions. Your approach is correct for well-behaved functions; for generic functions, though, it's way more complicated, see for example https://mauriciopoppe.github.io/function-plot/ |
Beta Was this translation helpful? Give feedback.
Plot has no special affordances for plotting functions. Your approach is correct for well-behaved functions; for generic functions, though, it's way more complicated, see for example https://mauriciopoppe.github.io/function-plot/