2
$\begingroup$

I want to plot the traces of the level surface of $z=4(x-1)^2+(y+2)^2+3$ parallel to the $xy$-, $zy$-, and $xz$-planes. There is already a similar question and answer but no matter how I change the values, I can not get nice traces of the level curves of $z=4(x-1)^2+(y+2)^2+3$ parallel to the $xy$-, $zy$-, and $xz$-planes. Here is the modified code that I use from the linked question and answer to plot the level curves parallel to the $xy$-plane:

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-1)^2 + (y+2)^2 + 3)]}, 
 MeshStyle -> Directive[Thick, Red], AxesLabel -> {"x", "y", "z"}]

What changes should I make to it so that it would produce nice traces of the level surface of $z=4(x-1)^2+(y+2)^2+3$ parallel to the $xy$-, $zy$-, and $xz$-planes?

$\endgroup$
0
$\begingroup$

It seems that you only need to adjust the variable and contour ranges for the values that your function assumes over those ranges. A quick Plot3D can help you pick suitable ranges:

ContourPlot3D[
 z, {x, -30, 30}, {y, -30, 30}, {z, 0, 600},
 Contours -> Range[0, 600, 75],
 ContourStyle -> {Opacity[0.3]},
 PlotPoints -> 30, MaxRecursion -> 3,
 Mesh -> {Range[0.5, 3.5], {0}}, 
 MeshFunctions -> {#3 &, Function[{x, y, z}, z - (4 (x - 1)^2 + (y + 2)^2 + 3)]},
 MeshStyle -> Directive[Thick, Red], AxesLabel -> {"x", "y", "z"}
]

Mathematica graphics

| improve this answer | |
$\endgroup$
1
$\begingroup$

Rather than using the surface as the mesh function you could just use #3& as the mesh function and plot the planes in the same plot while suppressing the surface, e.g.:

Plot3D[Evaluate[
  Join[{4 (x - 1)^2 + (y + 2)^2 + 3}, Range[0, 600, 100]]], {x, -30, 
  30}, {y, -30, 30}, 
 PlotStyle -> {None}~Join~Table[{LightBlue, Opacity[0.3]}, 7], 
 MeshFunctions -> {#3 &}, Mesh -> {Range[0, 600, 100]}, 
 PlotRange -> {0, 700}, ClippingStyle -> None, 
 MeshStyle -> Directive[Red, Thick], BoxRatios -> {1, 1, 1}]

enter image description here

You could also use SliceContourPlot3D,e.g.:

Show[SliceContourPlot3D[4 (x - 1)^2 + (y + 2)^2 - z, 
  Thread[z == Range[0, 600, 75]], {x, -30, 30}, {y, -30, 30}, {z, 0, 
   600}, Contours -> {-3}, ContourStyle -> Directive[Red, Thick], 
  ContourShading -> {{LightBlue, Opacity[0.5]}, None}, 
  PerformanceGoal -> "Quality"], 
 Plot3D[4 (x - 1)^2 + (y + 2)^2 + 3, {x, -30, 30}, {y, -30, 30}, 
  PlotStyle -> Opacity[0.3], Mesh -> None]]

I have not been able to suppress or remove the unfortunate artefact on the top contour.

enter image description here

| improve this answer | |
$\endgroup$

Your Answer

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