3
$\begingroup$

I have the following image enter image description here

where I have used Ticks -> {{{-0.75, "\[Pi]/4"}, 6, {-8, "Sun"}, 10}, {}, {}, {}}, to mark important points on the x-axis.

I would like to remove the tick marks under the Pi/4 and Sun labels, but don't know how to do this while retaining the labels.

If there is no way to do this, is there instead a way to label the x-axis without using Ticks as I have done?

For reference here is the code that establishes the axes:

shells = SphericalPlot3D[{6, 10}, {\[Theta], 0, Pi}, {\[Phi], 0,   
   2 Pi},  Mesh -> None, PlotPoints -> 50, ImageSize -> Large, 
  Boxed -> False, AxesOrigin -> {0, 0, 0},
  PlotStyle -> {Directive[Gray, Opacity[0.05]], 
    Directive[Gray, Opacity[0.05]]},
  PlotRange -> {{-14, 14}, {-14, 14}, {-14, 14}},
  AxesLabel -> {"\!\(\*SubscriptBox[\(x\), \(g\)]\) [kpc]", 
    "\!\(\*SubscriptBox[\(y\), \(g\)]\) [kpc]", 
    "\!\(\*SubscriptBox[\(z\), \(g\)]\) [kpc]"},
  AxesStyle -> Directive[Black, Bold, 15],
  LabelStyle -> Directive[Black, Bold, 15],
  Ticks -> {{{-0.75, "\[Pi]/4"}, 6, {-8, "Sun"}, 10}, {}, {}, {}},
  TicksStyle -> Directive[{Opacity[1]}]
  ]

Note: FrameStyle is not an option for SphericalPlot3D.

$\endgroup$

1 Answer 1

4
$\begingroup$

Specify a custom length of zero for those tick marks you want to hide, as in {-0.75, "\[Pi]/4", 0}, for example:

SphericalPlot3D[
 {6, 10}, {\[Theta], 0, Pi}, {\[Phi], 0, 2 Pi},
 Mesh -> None, PlotPoints -> 50, ImageSize -> Large,
 Boxed -> False, AxesOrigin -> {0, 0, 0},
 PlotStyle -> {Directive[Gray, Opacity[0.05]], 
   Directive[Gray, Opacity[0.05]]},
 PlotRange -> {{-14, 14}, {-14, 14}, {-14, 14}},
 LabelStyle -> Directive[Black, Bold, 15],
 
 Ticks -> {{{-0.75, "\[Pi]/4", 0}, 6, {-8, "Sun", 0}, 10}, {}, {}, {}},
 TicksStyle -> Directive[{Opacity[1]}]
]

modified with no unwanted ticks

$\endgroup$
2
  • $\begingroup$ Fantastic answer. Very intuitive and clean. $\endgroup$
    – asorlik
    Sep 21, 2022 at 17:25
  • $\begingroup$ @asorlik I am glad it helped! $\endgroup$
    – MarcoB
    Sep 21, 2022 at 18:00

Your Answer

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

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