3
$\begingroup$

In this 3D graphic, how do I cause both the axes labels and the arrows along the axes (with their arrowheads) to appear?

Create the arrows after the SphericalPlot3D. The axes labels show, but the arrows do not appear!

labelStyle[txt_] := Style[txt, FontFamily -> "Times", FontSlant -> "Italic", Bold, 20]

With[{origin = {0, 0, 0}, radius = 1, mult = 1.5},
  Show[
     SphericalPlot3D[radius, {\[Theta], \[Pi]/2, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, 
       PlotStyle -> Directive[Specularity[White, 75], Opacity[0.57, GrayLevel[0.65]]],
       Lighting -> "Neutral", Mesh -> None, PlotPoints -> 80, 
       MaxRecursion -> 8, Boxed -> False, Axes -> True, AxesOrigin -> {0, 0, 0}, 
       AxesLabel -> labelStyle /@ {"y", "x", "z"}, Ticks -> None, 
       PlotRange -> 1.25*radius, AxesStyle -> Thickness[0.0025], 
       ImageSize -> Full
     ],
     Graphics3D[
        {Arrowheads[0.015], Arrow[{origin, {mult*radius, 0, 0}}],
         Arrowheads[0.02], Arrow[{origin, {0, -mult*radius, 0}}],
         Arrowheads[0.02], Arrow[{origin, {0, 0, mult*radius}}]
         }, Boxed -> False, ImageSize -> Full]
     ]
]

Arrows created last but disappear

Instead, create the arrows before the SphericalPlot3D: the arrows show, but the axes labels disappear!

With[{origin = {0, 0, 0}, radius = 1, mult = 1.5},
   Show[
      Graphics3D[
        {Arrowheads[0.015], Arrow[{origin, {mult*radius, 0, 0}}],
         Arrowheads[0.02], Arrow[{origin, {0, -mult*radius, 0}}],
         Arrowheads[0.02], Arrow[{origin, {0, 0, mult*radius}}]
        }, Boxed -> False, ImageSize -> Full],
     SphericalPlot3D[radius, {\[Theta], \[Pi]/2, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, 
        PlotStyle -> Directive[Specularity[White, 75], Opacity[0.57, GrayLevel[0.65]]],
        Lighting -> "Neutral", Mesh -> None, PlotPoints -> 80, 
        MaxRecursion -> 8, Boxed -> False, Axes -> True, 
        AxesOrigin -> {0, 0, 0}, AxesLabel -> labelStyle /@ {"y", "x", "z"}, Ticks -> None, 
       PlotRange -> 1.25*radius, AxesStyle -> Thickness[0.0025], 
       ImageSize -> Full
      ]
   ]
]

Arrows created first but axes labels disappear

$\endgroup$
3
  • $\begingroup$ Use PlotRange -> All instead of PlotRange -> 1.25*radius. $\endgroup$ Commented Aug 24, 2018 at 20:05
  • $\begingroup$ @HenrikSchumacher: that did it, thanks! (Too obvious?) $\endgroup$
    – murray
    Commented Aug 24, 2018 at 20:11
  • $\begingroup$ Na, I also had to take a close look. First I tried to enlarged the Arrowheads and then I realized that only the tips of the arrow heads were cut of. I was quite puzzled first, in particular because I already added PlotRange -> All to the Show command. As a hint for the future: Try to put as many plot options in the most outer Show command. Within the Show command, the inheritence of plot options from the subordinate graphics opjects, while being logically correct and consistent, leads often to confusion. $\endgroup$ Commented Aug 24, 2018 at 20:16

2 Answers 2

1
$\begingroup$

Use PlotRange -> All instead of PlotRange -> 1.25*radius.

$\endgroup$
1
$\begingroup$

I think it might be better to drop the axes and the axes labels and label the arrowheads instead. Also, I suggest it is better to give all the options that apply to both the plot and the graphics as options to Show.

labelStyle[txt_] := 
  Style[txt, FontFamily -> "Times", FontSlant -> "Italic", Bold, 20]

With[{radius = 1, mult = 1.5},
  With[{arrowR = mult*radius, dtext = mult*radius + .1}, 
   Show[
     Graphics3D[
       {Thickness[0.0044], Arrowheads[0.02],
        Arrow[{{-arrowR, 0, 0}, {arrowR, 0, 0}}], 
        Text[labelStyle["y"], {dtext, 0, 0}],
        Arrow[{{0, arrowR, 0}, {0, -arrowR, 0}}], 
        Text[labelStyle["x"], {0, -dtext, 0}],
        Arrow[{{0, 0, -arrowR}, {0, 0, arrowR}}], 
        Text[labelStyle["z"], {0, 0, dtext}]}],
     SphericalPlot3D[radius, {θ, π/2, π}, {ϕ, 0, 2 π}, 
       PlotStyle -> Directive[Specularity[White, 75], Opacity[0.57, GrayLevel[0.65]]],
       Lighting -> "Neutral",
       Mesh -> None, 
       PlotPoints -> 80,
       MaxRecursion -> 8,
       Axes -> False],
     Boxed -> False,
     PlotRange -> All,
     ImageSize -> Full]]]

plot

$\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.