Plotting a Plane from a function using Makie

I just started using Makie to plot. Is it possible to plot a plane directly from a given function?
Eg. I have the following function:
y1(y2,y3) = -y2 -y3 - 1.0
I would like to give intervals for y2 and y3 and directly get a plot of y1.
I have already done this in Mathematica.
I know that it is possible to give single points and make a plane like in:
https://discourse.julialang.org/t/plotting-a-transparent-planes-boxes-with-makie/21875

but it’s not convenient for me because I would have to define the points by hand each time.

I’m not sure I understand your question correctly, but if you have multiple functions and you want to do the same things with those, you can pass them as a function argument and call them inside a function.
A (not working) example would be something like:

using Makie
y1(x2, x3) = -x2-x3-1.0

function plotfunction(y_2, y_3, f)
  # call f with the given arguments
  y_1 = f(y_2, y_3)
  # transform/compute the points as you wish
  mesh([y_1, y_2, y_3])
end

y2 = ...
y3 = ...
plotfunction(y2, y3, y1)

# define another function
y4(x2,x3) = -x2-x3-5.0
plotfunction(y2, y3, y4)

I hope that this helps, if not, and you could provide an example how you “define the points by hand each time”, I could alter this example as well.

Thanks for your answer! I think my first post was a bit unclear sorry abou that. I am trying to port what I did in mathemartica to julia. This is what I do in mathematica

y1[y2_, y3_] =  1 - y2 - y3; 
Plot3D[y1[y2, y3], {y2, -10, 10}, {y3, -10, 10}, 
 PlotStyle -> Opacity[0.3], PlotLabels -> "Manifold"]

The output looks like this (ignore the points):

test

The original is also interactive like in Makie plots!
The example I have shown here is very simple but later on i want to plot more complex manifolds.
It would be nice to have something like this where i only have to define the ranges for eg. y2 and y3.
Any ideas how I could implement this?

If you have two ranges, say x = 0:0.1:1 and y = 0:0.1:1, you can just do surface(x, y, f). Automatically selecting points in a smart way is in general not completely trivial, and I think there is only a 1D implementation in Julia here.

If you have ideas on how to do the 2D version, it would be a good PR to PlotUtils. Does Mathematica use an adaptive grid for 2D, or do they just take uniformly spaced points on x and y axis?

2 Likes

I am not sure what mathematica does since they are not open source. But i am pretty sure that they do not just use uniformly spaced points. Even very complex surfaces are always plotted very smoothly.

And you suggestion solved my problem. Thanks piever!