1
$\begingroup$

I have the following code:

ContourPlot3D[2x*z + 2y*z - y^3 - x^2 - 3z^2, {x, -3, 3}, {y, -3, 3}, {z, -3,3}]

which correctly produces a 3D plot of the function specified.

I was wondering if there was a way to demonstrate the critical points of the function on this plot? There are two:

  • (0,0,0) - saddle point
  • (1/6,1/3,1/6) - local max
$\endgroup$

2 Answers 2

2
$\begingroup$

One way to do this is to use Show, to combine two graphics:

Show[
 ContourPlot3D[
  2 x*z + 2 y*z - y^3 - x^2 - 3 z^2, {x, -3, 3}, {y, -3, 3}, {z, -3, 
   3}],
 Graphics3D[{PointSize[Large], Red, Point[{0, 0, 0}], 
   Point[{1/6, 1/3, 1/6}]}]
 ]
$\endgroup$
4
  • 1
    $\begingroup$ Not possible in 3D with Epilog, as anything in the Epilog is taken to be 2D and rendered on top. $\endgroup$
    – Szabolcs
    Oct 1, 2019 at 11:32
  • 1
    $\begingroup$ It is better to add ContourStyle -> Opacity[0.5] or another appropriate value to ContourPlot3D to show points behind the surface. And probably Mesh -> None, but I'm not sure what picture OP want. $\endgroup$
    – Alx
    Oct 1, 2019 at 11:34
  • $\begingroup$ @Szabolcs Indeed, I read the documentation after writing the answer :) It seems strange to me that there's nothing like Epilog3D. $\endgroup$
    – Carl Lange
    Oct 1, 2019 at 12:16
  • 3
    $\begingroup$ I think it might be because in 3D it doesn't make sense to have a layer behind (Prolog) and a layer in front of (Epilog) of the main graphics, like it does in 2D. (Of course, even if it doesn't make physical sense, it can certainly be rendered that way on a computer.) $\endgroup$
    – Szabolcs
    Oct 1, 2019 at 14:15
2
$\begingroup$

Related to the comments in the first answer:

1. Show with ContourStyle:

Show[
 ContourPlot3D[2 x*z + 2 y*z - y^3 - x^2 - 3 z^2, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, 
   ContourStyle -> Opacity[0.5]],
 Graphics3D[{PointSize[Large], Red, Point[{0, 0, 0}], Point[{1/6, 1/3, 1/6}]}]]

2. Graphics objects merging:

gr = ContourPlot3D[2 x*z + 2 y*z - y^3 - x^2 - 3 z^2, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}];
Graphics3D[{Opacity[0.5], gr[[1]], Opacity[1], {PointSize[Large], Red, Point[{0, 0, 0}], Point[{1/6, 1/3, 1/6}]}}, Axes -> True]

$\endgroup$

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.