6
$\begingroup$

I want to plot some wavefronts in Mathematica, and I'm having some trouble reining in one of the options for my ContourPlot3D.

More specifically, the documentation for ContourPlot3D says that the Contours option can be used in the form

ContourPlot3D[
  x^3 + y^2 - z^2
  , {x, -2, 2}, {y, -2, 2}, {z, -2, 2}
  , Contours -> {{-2, Red}, {2, Blue}}
  , Mesh -> None
]

to produce contours at those levels and with those colours, but when I try to implement that I get some pretty wonky behaviour. As a minimal example, consider the following plane wave:

L = π + 0.001;
ContourPlot3D[
 Arg[Exp[I z]]
 , {x, -L, L}, {y, -L, L}, {z, -L, L}
 , Contours -> Table[{ϕ, Hue[(ϕ + π)/(2 π)]}, {ϕ, -π, π, π/3}]
 , Mesh -> None
 ]

Unfortunately, it produces some pretty paltry output,

Mathematica graphics

with a bunch of contours missing. Weirdly enough, these contours do appear if I give it numerical values for the contours:

ContourPlot3D[
 Arg[Exp[I z]]
 , {x, -L, L}, {y, -L, L}, {z, -L, L}
 , Contours -> Table[{N[ϕ], Hue[(ϕ + π)/(2 π)]}, {ϕ, -π, π, π/3}]
 , Mesh -> None
 ]

Mathematica graphics

What's going on here? Is this a bug?

$\endgroup$
  • $\begingroup$ Well, this doesn't work right, either (dropping Hue): ContourPlot3D[Arg[Exp[I z]], {x, -L, L}, {y, -L, L}, {z, -L, L}, Contours -> Table[\[Phi], {\[Phi], -\[Pi], \[Pi], \[Pi]/3}], Mesh -> None] $\endgroup$ – Michael E2 Jul 21 '16 at 19:44
  • $\begingroup$ @Michael Huh, I just skipped that step. Yeah, that's some buggy behaviour right there. $\endgroup$ – Emilio Pisanty Jul 21 '16 at 19:46
  • $\begingroup$ Part of the problem is that ` Arg[Exp[I z]]` is discontinuous over the interval {z, -L ,L} and jumps over several contours near ±L. That's probably confusing the mesher. $\endgroup$ – Michael E2 Jul 21 '16 at 19:52
  • $\begingroup$ @JasonB That does seem like a bug, since Contours -> {N@\[Pi]/3} works fine. $\endgroup$ – Michael E2 Jul 21 '16 at 19:53
  • 4
    $\begingroup$ I'm gonna report this internally, but it doesn't really seem to be related to the form {val,_color} or to the Arg function. Compare the output of ContourPlot3D[z, {x, -1, 1}, {y, -1, 1}, {z, 0, 5}, Contours -> N /@ {\[Pi], E, EulerGamma}] to ContourPlot3D[z, {x, -1, 1}, {y, -1, 1}, {z, 0, 5}, Contours -> {\[Pi], E, EulerGamma}] $\endgroup$ – Jason B. Jul 21 '16 at 19:53

Your Answer

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

Browse other questions tagged or ask your own question.