Can we use RegionFunction with Plot3D for equalities? This answer (Plot multivariable function with constraints) has shown the use of RegionFunction with inequalities, but the same commands don't work for equality constraints. Any way out?

  • 1
    $\begingroup$ Can you show an example of what you are trying to achieve, with the code you currently have? Did you see the use of PlotStyle -> None in the linked question's answers to obtain only the boundary of the region identified with the inequality? That would be functionally equivalent to plotting the equality. $\endgroup$ – MarcoB Apr 24 '18 at 19:37
  • $\begingroup$ @MarcoB, the options given in the other answer in that link are not applicable in this case. I used Plot3D[x + 2 y, {x, -Sqrt[5], Sqrt[5]}, {y, -Sqrt[5], Sqrt[5]}, RegionFunction -> Function[{x, y}, x^2 + y^2 - 1]] and it gives a circular 'hole' in the plot of x+2y, instead of showing just the circle on top of the plot of x+2y $\endgroup$ – sant Apr 24 '18 at 19:57

This approach may not be the most direct, but here is how I envisioned using the techniques shown in kglr's answer to the linked question (Q157490) to achieve your goal, as I understand it:

  (* This generates the plot of the surface of interest *)
  Plot3D[x + 2 y, {x, -Sqrt[5], Sqrt[5]}, {y, -Sqrt[5], Sqrt[5]}],

  (* This generates the region boundary *)
    x + 2 y, {x, -Sqrt[5], Sqrt[5]}, {y, -Sqrt[5], Sqrt[5]},
    RegionFunction -> Function[{x, y}, x^2 + y^2 < 1],
    BoundaryStyle -> Directive[Thick, Black],
    PlotStyle -> None, Mesh -> None

3D plot with boundary


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.