Plotting functions directly in Makie

A syntax from Plots.jl that I love is plot(x->x^2), and plot(cos), where I can add a second and third argument to specify a range of x-values. This is really an example of delicious syntax - straight to the point.

I say, if the function can be smart enough to create arrays of corresponding points using the function passed, then let it do it, so that I don’t have to define variables to hold the values when I only want to use it for plotting.

Is this possible in Makie? I have tried a couple of things are had a small look around in the example gallery, but I have not seen any indication that this is implemented. If it is correct that it is not, are there plans to make it happen?

1 Like

lines(0..10, sin) works for example, there are a couple others, but not a single function without an interval as far as I know

2 Likes

For completeness, both of the examples below work. In order to understand it, I view it as still giving xvalues and then yvalues as intervals, ranges, and functions instead of datapoints:

using GLMakie
plot(0..2, x->x^2)
plot(0:0.1:2, x->x^3)
1 Like