4
$\begingroup$

I am looking for an easy way to force this plot to label the $y$ axis with numbers below the axis automatically in the given view point. Now the label switches to the bottom when the view point reaches a certain angle, but I would like to have the labeling always below the $y$-axis.

The existing answers could not help so far (mostly for 2D only). Using the Epilog function changes the font and the angle as far as I was able to test it.

Furthermore, I would like to mark the ticks at: {{0, -20, 0}, {0, -10, 0}, {0, 0, 0}, {"r/2", 0, 0}, {"r", 0, 0}} with a little black cross, but cannot work it out.

Are there ways to solve these problems? Many thanks in advance.

circle3D[centre_: {0, 0, 0}, radius_: 20, normal_: {0, 0, 1},
angle_: {0, 2 Pi}] :=Composition[Line,
Map[RotationTransform[{{0, 0, 1}, normal}, centre], #] &,
Map[Append[#, Last@centre] &, #] &,
Append[DeleteDuplicates[Most@#], Last@#] &, Level[#, {-2}] &,
MeshPrimitives[#, 1] &, DiscretizeRegion, If][
First@Differences@angle >= 2 Pi, Circle[Most@centre, radius],
Circle[Most@centre, radius, angle]]

cGr = Graphics3D[{Thick, Dashed, circle3D[{0, 0, 0}, 20]}];
c1 = Graphics3D[{Thick, Dashed, circle3D[{0, 0, 20}, 20]}];

Show[c1,Ticks -> {Automatic,Table[i, {i, -20, 20, 10}], 
Automatic},AxesStyle -> Thickness[0.004], Boxed -> False, Axes -> 
True,AxesOrigin -> {0, 0, 0},Boxed -> False,PlotRange -> {{-20, 20}, 
{-20, 20}, {0, 30}}, ImagePadding -> {{0, 40}, {40, 70}},
ViewPoint -> {0.8 Pi, -1.5 Pi, 0.20 Pi}]
$\endgroup$
6
$\begingroup$

Here is a brute-force method that simply suppresses the tick labels automatically generated, and creates Graphics3D[Text[... objects to put where we want them.

xticks = Table[
    Text[ToString @ n, {n, 0, -1.5}],
    {n, -20, 20, 10}
];
yticks = Table[Text[ToString @ n, {0, n, -1.5}],
    {n, -20, 20, 10}
];
Show[c1,
    Graphics3D @ {xticks, yticks},
    Ticks -> {Automatic, Automatic, Automatic},
    AxesStyle -> Thickness[0.004],
    Boxed -> False, Axes -> True, TicksStyle -> {
        Directive[FontOpacity -> 0, FontSize -> 0],
        Directive[FontOpacity -> 0, FontSize -> 0],
        Automatic
    },
    AxesOrigin -> {0, 0, 0},
    Boxed -> False, PlotRange -> {{-20, 20}, {-20, 20}, {0, 30}},
    ImagePadding -> {{0, 40}, {40, 70}},
    ViewPoint -> {0.8 * Pi, -1.5 * Pi, 0.2 * Pi}
]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Thanks for the answer. This is a fine solution. $\endgroup$ – StephanJ Feb 22 '16 at 14:29
  • 1
    $\begingroup$ The signs of the labels are preserved if you use ToString instead of IntegerString. $\endgroup$ – Will.Mo Nov 14 '17 at 9:16
  • $\begingroup$ @Will.Mo thanks for catching that. $\endgroup$ – Jason B. Nov 14 '17 at 14:33

Your Answer

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

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