TransWikia.com

Show not displaying multiple ContourPlot3D's

Mathematica Asked by Charlie H. on January 25, 2021

I’m trying to make an image that looks like this:
enter image description here

I’m not sure if this is the best way to do it, but this is the relevant part of my code.

contourCurve = ContourPlot3D[
   {z == g[x, y], z == g[p, q]},
   {x, -1, 1}, {y, 0.11, 1.7}, {z, 0, 3},
   ContourStyle -> {Directive[Gray, Opacity[1]], 
     Directive[ Blue, Opacity[0]]},
   ColorFunction -> (Blend[{Brown, Gray}, #3] &),
   (*MeshStyle[Rule]{1[Rule] Gray,2[Rule] None },*)
   Mesh -> None,
   BoundaryStyle -> {2 -> None, {1, 2} -> None, 1 -> None}
   ];
contourPlane = ContourPlot3D[
   {z == g[x, y], z == g[p, q]},
   {x, -1, 1}, {y, 0.11, 1.7}, {z, 0, 3},
   ContourStyle -> {Directive[Gray, Opacity[0]], 
     Directive[ Blue, Opacity[0.4]]},
   (*MeshStyle[Rule]{1[Rule] Gray,2[Rule] None },*)
   Mesh -> None,
   BoundaryStyle -> {2 -> None, {1, 2} -> { Blue, Thickness[0.005]}, 
     1 -> None}
   ];
Show[{
  Graphics3D[{
    centerPoint,
    surfNormArrow,
    gradArrow,
    tangArrow
    }],
  contourCurve,
  contourPlane
  },
 Axes -> False,
 AxesLabel -> {x, y, z},
 Boxed -> False,
 PlotRange -> {{-0.75, 0.75}, {0.1, 2}, {0.1, 1}}
 ]

The above graphic was actually made with this code. However, after saving, reopening, and reevaluating, I am only able to get one part of the graphic. So it looks like one of these two pictures, depending on if I list contourCurve or contourPlane first within the Show command.

enter image description here
enter image description here

I’m not sure if I’m doing something wrong, or I encountered some weird error. I’m also open to suggestions if there are better ways to accomplish what I’m trying to accomplish.

One Answer

I figured out the answer. I have no idea why this works when my original code doesn't. All I had to do was switch the rules for BoundaryStyle[... {1,2}->xxxx ...]. So it should read like this:

contourCurve = ContourPlot3D[
   {z == g[x, y], z == g[p, q]},
   {x, -1, 1}, {y, 0.11, 1.7}, {z, 0, 3},
   ContourStyle -> {Directive[Gray, Opacity[1]], 
     Directive[ Blue, Opacity[0]]},
   ColorFunction -> (Blend[{Brown, Gray}, #3] &),
   (*MeshStyle[Rule]{1[Rule] Gray,2[Rule] None },*)
   Mesh -> None,
   BoundaryStyle -> {2 -> None, {1, 2} -> { Blue, Thickness[0.005]}, 1 -> None}
   ];
contourPlane = ContourPlot3D[
   {z == g[x, y], z == g[p, q]},
   {x, -1, 1}, {y, 0.11, 1.7}, {z, 0, 3},
   ContourStyle -> {Directive[Gray, Opacity[0]], 
     Directive[ Blue, Opacity[0.4]]},
   (*MeshStyle[Rule]{1[Rule] Gray,2[Rule] None },*)
   Mesh -> None,
   BoundaryStyle -> {2 -> None, {1, 2} -> None, 
     1 -> None}
   ];

Answered by Charlie H. on January 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP