Kevinpgalligan / ka

A calculator language.
MIT License
5 stars 0 forks source link

Plotting #14

Open Kevinpgalligan opened 5 months ago

Kevinpgalligan commented 5 months ago

With the addition of sets / arrays / lists / whatever (https://github.com/Kevinpgalligan/ka/issues/2), it would be cool to add a minimal plotting API. Line plots, scatter plots, histograms.

xs = sample(UniformInt(1, 100), 100)
xs = [1, 100) <---- alternative, using interval syntax
E = Gaussian(0, 10)
ys = {5*x + E : x in xs}
plot(xs, ys)

Might have to add optional parameters to the syntax so that the plot can be customised (markers, colours, grid, axis labels, legend, various other style options, x bounds, y bounds). Alternatively, separate functions could be called to customise the plot before it's shown.

Kevinpgalligan commented 4 months ago

Brainstorming. I think I'll add keyword arguments to the grammar, like below. And strings.

plot(xs, ys, xlabel: "Time", ylabel: "Distance", xbound_low: 0, ybound_low: 0, marker: "o")