8
$\begingroup$

I came up with this method to plot the traces of the surface $z=4x^2+y^2$, in this case for $z=1$, 2, 3, and 4.

ContourPlot3D[{z == 4 x^2 + y^2, z == 1, z == 2, z == 3, 
  z == 4}, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01},
 ContourStyle -> {Opacity[0.3]},
 PlotPoints -> 30, MaxRecursion -> 3,
 Mesh -> {{1, 2, 3, 4}}, MeshFunctions -> {#3 &},
 MeshStyle -> {Thick, Red},
 AxesLabel -> {"x", "y", "z"}]

Which produces this image:

enter image description here

I am now looking for a way to hide the surface $z=4x^2+y^2$, but keep the planes and the mesh curves.

Any suggestions?

Update:

Consider obtaining traces for the surface $z=y^2-x^2$ using technique shown by MichaelE2.

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5}, 
 Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]}, 
 PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}}, 
 MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]

Image:

enter image description here

ContourPlot3D[x, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5}, 
 Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]}, 
 PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}}, 
 MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]

Image:

enter image description here

ContourPlot3D[y, {x, -2, 2}, {y, -2, 2}, {z, -1.5, 1.5}, 
 Contours -> {-1, 0, 1}, ContourStyle -> {Opacity[0.3]}, 
 PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}}, 
 MeshFunctions -> {Function[{x, y, z}, z - (y^2 - x^2)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]

Image:

enter image description here

I think this gives students a very simple way to get the traces for a quadratic surface.

$\endgroup$
  • 4
    $\begingroup$ How about changing ContourStyle -> {Opacity[0.3]} to ContourStyle -> {Opacity[0.0], Opacity[0.3], Opacity[0.3], Opacity[0.3], Opacity[0.3]} ? $\endgroup$ – Gregory Rut Jun 5 '15 at 20:18
  • $\begingroup$ @GregoryRut: This worked very well, but I also had to include a BoundaryStyle->None. Thanks for the help and the good idea. $\endgroup$ – David Jun 5 '15 at 21:52
  • $\begingroup$ @GregoryRut Somewhat better is ContourStyle -> {None, Opacity[0.3], Opacity[0.3], Opacity[0.3], Opacity[0.3]}. The plot will be almost 20% smaller. (Omitting the paraboloid altogether makes the plot almost 50% smaller.) $\endgroup$ – Michael E2 Jun 5 '15 at 22:05
  • $\begingroup$ Question: I don't see any mention of derivatives or integrals anywhere in the question, so why put in the calculus-and-analysis tag? Here, you are merely slicing surfaces… $\endgroup$ – J. M. will be back soon Jun 5 '15 at 23:08
  • $\begingroup$ @Guesswhoitis. First, this problem is from Stewart's Early Transcendentals Calculus Book 5th Ed (we have a bunch of free books on reserve so students don't have to pay $250 to buy a book), section 12.6, Examples #4 and 5. So it is a very seriously hard calculus problem (students are expected to draw it by hand). Second, if some folks search this site for calculus examples by using a tag, then the calculus tag could be helpful. How's that? $\endgroup$ – David Jun 6 '15 at 5:00
8
$\begingroup$

You could omit the (paraboloid) surface and use its formula as a mesh function:

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01}, 
 Contours -> Range[4], ContourStyle -> {Opacity[0.3]}, 
 PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {{0}}, 
 MeshFunctions -> {Function[{x, y, z}, z - (4 x^2 + y^2)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> Automatic]

Mathematica graphics


You may like the simpler approach above, but if you want to get fancy, you could highlight the ellipses.

ContourPlot3D[z, {x, -2, 2}, {y, -2, 2}, {z, 0, 4.01}, 
 Contours -> Range[4], ContourStyle -> {Opacity[0.3]}, 
 PlotPoints -> 30, MaxRecursion -> 3, Mesh -> {Range[0.5, 3.5], {0}}, 
 MeshShading -> {
  {Opacity[ 0.2], ##} & @@@
   ("DefaultPlotStyle" /. (Method /. Charting`ResolvePlotTheme["Default", ContourPlot3D])),
  {Opacity[0.7], ##} & @@@
   ("DefaultPlotStyle" /. (Method /. Charting`ResolvePlotTheme["Default", ContourPlot3D]))
  }, 
 MeshFunctions -> {#3 &, Function[{x, y, z}, z - (4 x^2 + y^2)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> {"x", "y", "z"}]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Yep, the first method will be easier for my students to understand, so that is my preference. I think I understand what it does so I will be able to explain it to the students. It plots the level surface for z, and because of Mesh->Range[4], it plots the level surfaces z=1, z=2, z=3, z=4, which are the four planes. Then the MeshFunctions->{Function[x,y,z], z-(4x^2+y^2)]} Sketch all the points on each plane that satisfies z-(4x^2+y^2)=0. Have I got that correct? Also, I used your technique to get the traces for the surface z=y^2-x^2. See the update in my original post. $\endgroup$ – David Jun 5 '15 at 22:37
  • $\begingroup$ @David, Yep, you got it. And you can change the range to get a denser slices; e.g. Range[0, 4, 0.2]. Note that ContourPlot won't plot an isolated point. You'd have to offset the range slightly to mark the bottom of the paraboloid; e.g. Range[0.002, 4.002, 0.5]. (You know, every now and then computing these plots are crashing my kernel, including my plots and yours. Nothing reproducible.) $\endgroup$ – Michael E2 Jun 5 '15 at 23:24
  • $\begingroup$ Me too. Ever since updating to Mathematica 10.1, I've been experiencing all kinds of problems. The Beep, telling me the Kernel quit. I've had lockups where I have had to Force Quit Mathematica (I'm on a MacBook Pro 10.10.3), and I have had crash reports. I've sent several of them to Wolfram Support along with some notebooks. $\endgroup$ – David Jun 6 '15 at 2:57

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.