5
$\begingroup$

I am trying to render a hemisphere with RegionPlot3D, but I want the axes to be obscured by the plot. My current code is as follows:

RegionPlot3D[
x^2 + y^2 + z^2 <= 36 && y >= 0, {x, -8, 8}, {y, -8, 8}, {z, -8, 8}, 
AxesLabel -> {x, y, z}, PlotPoints -> 70, AxesStyle -> Large, 
AxesOrigin -> {0, 0, 0}, Boxed -> False]

But the axes show through:

enter image description here

$\endgroup$

2 Answers 2

9
$\begingroup$

One possibility it to draw the axes separately and use Show

I used the code to draw the axis from https://math.stackexchange.com/questions/16498/traditional-axes-in-3d-mathematica-plots

Now you can do,

axes[x_, y_, z_, f_, a_] := 
 Graphics3D[
  Join[{Arrowheads[a]}, 
   Arrow[{{0, 0, 0}, #}] & /@ {{x, 0, 0}, {0, y, 0}, {0, 0, 
      z}}, {Text[
     Style["x", FontSize -> Scaled[f]], {0.9*x, 0.1*y, 0.1*z}], 
    Text[Style["y", FontSize -> Scaled[f]], {0.1 x, 0.9*y, 0.1*z}], 
    Text[Style["z", FontSize -> Scaled[f]], {0.1*x, 0.1*y, 0.9*z}]}]];

Show[RegionPlot3D[
  x^2 + y^2 + z^2 <= 36 && y >= 0, {x, -8, 8}, {y, -8, 8}, {z, -8, 8},
  AxesLabel -> {x, y, z},
  PlotPoints -> 70,
  AxesOrigin -> {0, 0, 0},
  Axes -> False, (* make sure to turn this off here*)
  Boxed -> False],
 axes[10, 10, 10, 0.05, 0.02], (*this draws axis manually*)
 PlotRange -> All
 ]

Mathematica graphics

$\endgroup$
8
$\begingroup$

Draw and tailor axes separately (under different names if needed).

axesOnly=Graphics3D[{
        Black , Arrowheads[0.02]
  
   , Arrow[Tube[{{0, 0, 0}, {10, 0, 0}},.05]]
   , Arrow[Tube[{{0, 0, 0}, {-10, 0, 0}},.05]]
   , Text[Style["x", Italic, Bold, 14], {11, 0, 0}]
   
   , Arrow[Tube[{{0, 0, 0}, {0, 10, 0}}, .05]]
   , Arrow[Tube[{{0, 0, 0}, {0, -10, 0}}, .05]]
   , Text[Style["y", Italic, Bold, 14], {0, 11, 0}]
   
   , Arrow[Tube[{{0, 0, 0}, {0, 0, 10}},.05]]
   , Arrow[Tube[{{0, 0, 0}, {0, 0, -10}}, .05]]
   , Text[Style["z", Italic, Bold, 14], {0, 0, 11}]
  
   }
  (**)
  ]

enter image description here

Use opacity and block axes and box frame.

Show[
 RegionPlot3D[x^2 + y^2 + z^2 <= 36 && y >= 0
  , {x, -12, 12}, {y, -12, 12}, {z, -12, 12}
  , PlotPoints -> 70
  , PlotStyle -> {Opacity[1]}
  , AxesEdge -> {None, None, None}
  , Boxed -> False
 (*, Lighting -> {White, "Ambient"}*)
 ,ImageSize->600
  ],
 axesOnly
 ]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.