2
$\begingroup$

This is certainly very basic, but rusty as I am with Mathematica, I'm still unable to figure this out. I need to show white empty axes in a 3D graphics, with labels and thicks showing on the exterior side of the 3D box. Here's a MWE code to play with:

Plot3D[
 x y,
 {x, -10, 10},
 {y, -10, 10},
 PlotPoints -> {30, 30},
 PlotRange -> {{-10, 10}, {-10, 10}, {-3, 3}},
 Axes -> True,
 AxesOrigin -> {0, 0, 0},
 Ticks -> None,
 AxesStyle -> Directive[GrayLevel[1]],
 AxesLabel -> None,
 (*Box->{
 Style["X",  Bold, 14],
 Style["Y",  Bold, 14],
 Style["Z",  Bold, 14]
 },*)
 ColorFunction -> "Rainbow",
 ImageSize -> 700,
 Method -> {"RotationControl" -> "Globe"},
 SphericalRegion -> True
 ]

Preview, with the issue shown in red:

enter image description here

As shown on the picture, I need to keep the white axes as they are (without ticks and labels), and put all of them on the 3D box itself. So how can I customize this?

Also, if possible, the ticks and labels shouldn't switch sides on the box, while rotating the view (this is annoying).

Of course, if I remove most of the options in that code above, then I'll get the ticks and labels on the box, but I'll lose the white axes in the middle.

$\endgroup$
2
$\begingroup$

Add the axes "by hand" using explicit Graphics objects? It's easier to automatically obtain the ticks etc and create the axes, rather than the opposite:

Show[
 Plot3D[
  x y,
  {x, -10, 10}, {y, -10, 10}, PlotPoints -> {30, 30},
  PlotRange -> {{-10, 10}, {-10, 10}, {-3, 3}},
  Axes -> True, AxesLabel -> {"x", "y", "z"},
  ColorFunction -> "Rainbow", ImageSize -> 700,
  Method -> {"RotationControl" -> "Globe"}, SphericalRegion -> True
 ],
 Graphics3D[{White, Thick,
   Line[{{0, -100, 0}, {0, 100, 0}}],
   Line[{{0, 0, -100}, {0, 0, 100}}],
   Line[{{-100, 0, 0}, {100, 0, 0}}]
 }]
]

3D plot with added axes

$\endgroup$
2
  • $\begingroup$ Is it possible to make the plot so that the ticks and labels don't switch sides, after you rotate the view? Currently, after you rotate the view, the ticks/labels are frequently jumping around and it's annoying. $\endgroup$ – Cham Dec 7 '20 at 16:57
  • 3
    $\begingroup$ @Cham I think you are looking for AxesEdge for that. $\endgroup$ – MarcoB Dec 7 '20 at 17:00

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.