2
$\begingroup$

Suppose I have Graphics3D objects like Arrows that I'd like to label, such as

ClearAll[o, e1, e2, e3]

o = {0, 0, 0};
{e1, e2, e3} = IdentityMatrix[3];

justgrid[f1_, f2_, f3_, c1_, c2_, c3_, s1_, s2_, s3_] := Module[{ts},
  
  ts = 0.02;
  Graphics3D[{
    
    AspectRatio -> 1
    , Black
    , PointSize[0.015]
    , Table[
     Point[i f1 + j f2 + k f3], {i, 0, s1 + 1}, {j, 0, s2 + 1}, {k, 0,
       s3 + 1}]
    , Opacity[0.05]
    , Table[
     Parallelepiped[i f1 + j f2 + k f3, {f1, f2, f3}], {i, 0, s1}, {j,
       0, s2}, {k, 0, s3}]
    
    , Arrowheads[0.05]
    , Opacity[1]
    , Red // Darker // Darker
    , Arrow[Tube[{o, f1}, ts]]
    , Black
    , Text[c1, f1/2]
    
    , Green // Darker // Darker
    , Arrow[Tube[{o, f2}, ts]]
    , Black
    , Text[c2, f2/2]
    
    , Blue // Darker // Darker
    , Arrow[Tube[{o, f3}, ts]]
    , Black
    , Text[c3, f3/2]
    
    , Opacity[0.05]
    , Pink // Lighter 
    , Parallelepiped[o, {(s1 + 1) f1, (s2 + 1) f2, 0.01 f3}]
    , Parallelepiped[o, {(s2 + 1) f2, (s3 + 1) f3, 0.01 f1}]
    
    }]
  ]

justgrid[e1, e2, e3,
  "\!\(\*SubscriptBox[\(e\), \(1\)]\)", "\!\(\*SubscriptBox[\(e\), \
\(2\)]\)", "\!\(\*SubscriptBox[\(e\), \(3\)]\)", 1, 1, 1]

Observe that my labels are obscured by the objects, but it is not easily obvious what directions to offset them to make them show up better:

labels in 3d graphics that are not easy to see

Is it possible to use the Plot3D Callout[] mechanism within Graphics3D to automatically position the labels in a non-obscured fashion?

If not, is there a way to create a background behind the label (relative to the viewpoint), so that the label shows up more clearly?

$\endgroup$

1 Answer 1

4
$\begingroup$

Maybe you can show up the labels more clearly including a labeled in the Text objects as follows:

Text[Labeled[c1, "", Background -> White], f1/2]

Applying this to the three Text gives the output (with FontSize->14)

enter image description here

Even you can add a Framed as follows:

Text[Labeled[Framed@c1, "", Background -> White], f1/2]

to get

enter image description here

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