4
$\begingroup$

This question already has an answer here:

This code:

arrowAxes[arrowLength_] := 
  Map[{Apply[RGBColor, #], Arrow[Tube[{{0, 0, 0}, #}]]} &, arrowLength IdentityMatrix[3]];

Graphics3D[
  {Sphere[{1, 1, 1}], arrowAxes[3]},
  Axes -> True,
  Boxed -> False, 
  AxesOrigin -> {0, 0, 0},
  AxesStyle -> Opacity[0], 
  TicksStyle -> Opacity[1]]

will produce these plots:

enter image description here

enter image description here

enter image description here

How not to display tick and labels that are behind the sphere? (this is the case in the first and second picture above; third picture is correct in that sense, since blue axis is in front of the sphere)


There is a suspicion that this may be a bug, related to AxisOrigin. Therefore, I am adding tag "bugs".

$\endgroup$

marked as duplicate by Kuba, rhermans, bobthechemist, Michael E2, Silvia Nov 21 '14 at 19:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $\begingroup$ I think you need AxesEdge like in this question Method -> {“AxesInFront” -> False} for Graphics3D. But I'm not sure because you want to hide ticks behind Sphere and then you are saying that the third example is correct... $\endgroup$ – Kuba Nov 21 '14 at 13:13
  • $\begingroup$ Thanks, @Kuba, it looks the question you linked could be truly useful; the third example is right, the reason is blue axis is in front of the sphere, seen from the viewer, for that particular coordinate system placement. $\endgroup$ – Adrian Nov 21 '14 at 13:20
  • $\begingroup$ 1. First of all suspicion is not enough to give that Tag. 2. I don't think it is a bug. If you focus on the link I've given you will see that it is the way it is working. Axes which are not created with AxesEdge are different objects which will always be on top of 3D graphics... $\endgroup$ – Kuba Nov 21 '14 at 14:10
  • 2
    $\begingroup$ @Kuba, AxisOrigin doesn't create new axis, only shapes it, but as well it introduces this unproper and unexpected behaviour. It's not mentioned anyhow in docs, so it really looks like a bug $\endgroup$ – funnyp0ny Nov 21 '14 at 14:35
  • 1
    $\begingroup$ @funnypony I think it's just the things appears to be. The answer under Kuba's question came from a WRI employee, thus is at least "semi-official". Actually I guess the appeared "axis" when using AxisOrigin or not using it are constructed from different base/origin. $\endgroup$ – Silvia Nov 22 '14 at 8:40
4
$\begingroup$

It seems AxesOrigin property spoils everything. A bug maybe.. I can suggest 2 way outs:

first, simply:

Graphics3D[{arrowAxes[3], Sphere[{1, 1, 1}]}, Axes -> True, Boxed -> False, 
 AxesEdge -> {{0, -1}, {0, -1}, {0, -1}}, 
 AxesStyle -> Opacity[0], TicksStyle -> Opacity[1]]

enter image description here

This gives what you want, but i don't know how to specify the the axesrange explicitly

secondly and you can try draw your figures in Plot3D environment:

Show[
 Plot3D[0, {x, 0, 3}, {y, 0, 3}, PlotRange -> {{0, 3}, {0, 3}, {0, 3}},
  AxesEdge -> {{0, -1}, {0, -1}, {0, -1}}, BoxRatios -> {1, 1, 1}, 
  Mesh -> None, Boxed -> False, PlotStyle -> Opacity@0, 
  BoundaryStyle -> None],
 Graphics3D[{arrowAxes[3], Sphere[{1, 1, 1}]}]]

(this gives the same)

$\endgroup$
  • $\begingroup$ This is not a bug. In every plot the axis visibility overrides the opacity setting. Evaluate Graphics3D[Sphere[{1, 1, 1}], AxesOrigin -> {1, 1/2, 3}, Axes -> True] and you'll realise that even though the sphere is opaque, the axes (and ticks) are still visible behind it. This is the standard. In your (@Jens's) code, you(he) replaces the axes with a graphics primitive (ArrowTube). Since graphics primitives respect opacity, he demonstrates how leaving the ticks in place, shows through the sphere but the tubed axis doesn't. As he says, the ticks can be made by hand if need be... $\endgroup$ – gpap Nov 21 '14 at 15:57
  • 1
    $\begingroup$ @gpap, no it's not standard. This problem arises ONLY when you use AxesOrigin property. Draw anything in 3D without AxeisOrigin and you'll get normal predictable behaviour, where back axis doesn't overlay objects. The AxisOrigin property introduces this unproper and unexpected behaviour. It's not mentioned anyhow in docs, so why one shouldn't consider it a bug? $\endgroup$ – funnyp0ny Nov 21 '14 at 16:13
  • 1
    $\begingroup$ This is because ONLY when you use axes origin, mathematica stops readjusting the axes according to the viewpoint. $\endgroup$ – gpap Nov 21 '14 at 16:17
2
$\begingroup$

I just changed your code a little bit, to TickStyle->None

arrowAxes[arrowLength_] := 
  Map[{Apply[RGBColor, #], Arrow[Tube[{{0, 0, 0}, #}]]} &, 
   arrowLength IdentityMatrix[3]];

Graphics3D[{Sphere[{1, 1, 1}], arrowAxes[3]}, Axes -> True, 
 Boxed -> False, AxesOrigin -> {0, 0, 0}, AxesStyle -> Opacity[0], 
 TicksStyle -> None]

enter image description here

$\endgroup$
  • $\begingroup$ Jason, thanks, I appreciate this, but this hides ticks altogether... I want them where they are not hiden by the sphere $\endgroup$ – Adrian Nov 21 '14 at 13:06

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