Plots
Plots copied to clipboard
Using values from external files in formulas
Hi, thanks for your work on Plots, it is really useful!
My use-case is mostly applying formulas to arbitrary values (simulation output) to further process the signal.
I would like to be able to "import" values from external files.
For example CSV files formatted with x, y
per lines would be available as f(x) = y
, to be able to plot it.
I wouldn't mind and could contribute an inelegant hack of importing a hardcoded filename on startup, I would just need an idea of where to look for, specifically where in the parser or in the formula calculation, to feed the imported values.
I guess this might not be a very common use-case?
Hi Simon, glad to hear Plots has been useful to you!
Your use-case is perhaps not that common, and I've personally not yet needed to do this. Adding statistical functions would be quite an expansion of the app's scope. However it's an interesting feature, and I believe Desmos does have a similar one, so it's not without precedent.
At present Plots draws its graphs in a slightly unique way: it evaluates the function many times at each pixel (on the GPU, in a shader), checking for sign changes. Unfortunately, this would make it harder to draw external data, compared to other programs which just draw lines between the function evaluations.
I may in the future add support for parametric equations, which would probably require implementing a new drawing method based on drawing lines between sampled points. In this case, drawing external data would be quite easy to implement. Until then, I don't see an easy way to implement this, I'm afraid.
Until this is implemented: For serious data visualization, I recommend that you take a look at gnuplot.