1
$\begingroup$

I want to plot the cross-sections of $z=4x^2+y^2$ parallel to the $yz$-plane. I have tried the below code

ContourPlot3D[x, {x, -6, 6}, {y, -6, 6}, {z, -1, 40}, 
 Contours -> {-6, -4, -2, 0, 2, 4, 6}, 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]

and here is the output I get

enter image description here

It seems that I do not get any parabolas for $x=\pm4,\pm6$. How do I fix this?

$\endgroup$
  • 1
    $\begingroup$ Either adjust the PlotRange in your method, or just use Plot3D[] directly: Plot3D[4 x^2 + y^2, {x, -6, 6}, {y, -6, 6}, BoundaryStyle -> None, BoxRatios -> {1, 1, 3}, Mesh -> 10, MeshFunctions -> {#1 &}, MeshStyle -> Red, PlotStyle -> None]. $\endgroup$ – J. M. will be back soon Mar 27 '18 at 8:31
1
$\begingroup$

A simple approach by using Show:

par = Plot3D[4 x^2 + y^2, {x, -10, 10}, {y, -10, 10}, 
BoundaryStyle -> None, BoxRatios -> {1, 1, 2}, PlotStyle -> Cyan, Mesh -> None];

sec = ContourPlot3D[x, {x, -10, 10}, {y, -10, 10}, {z, 0, 500}, 
Contours -> {-6, -4, -2, 0, 2, 4, 6}, 
ContourStyle -> {Opacity[0.3]}, PlotPoints -> 30, MaxRecursion -> 3,
Mesh -> {{0}}, BoxRatios -> {1, 1, 2}, 
MeshFunctions -> {Function[{x, y, z}, z - (4 x^2 + y^2)]}, 
MeshStyle -> Directive[Thickness[0.02], Red], AxesLabel -> Automatic];

Show[{par, sec}, Boxed->False]

enter image description here

$\endgroup$

Your Answer

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