2
$\begingroup$

When I try to use a pre-defined expression in RegionFunction, I get errors:

f = x^2 + y^2 + z^2 - 1
g = x+y+z
ContourPlot3D[f == 0, {x, -3, 3}, {y, -3, 3}, {z, -2, 5}, 
 RegionFunction -> Function[{x, y, z}, 0 <= g]]

I've tried to fix this with using eg "With", but I haven't been able to. Can anyone help me?

$\endgroup$
1
  • $\begingroup$ ContourPlot3D like other plotting functions has the attribute HoldAll so, as pointed out by @cvgmt, must be evaluated. $\endgroup$
    – Bob Hanlon
    Commented Oct 1, 2022 at 15:09

1 Answer 1

4
$\begingroup$

Use Evaluate.

f = x^2 + y^2 + z^2 - 1;
g = x + y + z;
ContourPlot3D[f == 0, {x, -3, 3}, {y, -3, 3}, {z, -2, 5}, 
 RegionFunction -> Function[{x, y, z}, 0 <= g // Evaluate], 
 RegionBoundaryStyle -> None]
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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