1
$\begingroup$

I used the following code to plot three 3D boxes:

x = Graphics3D[{Blue, Opacity[0.2
    ], Parallelepiped[{0, 0, 
     0}, {{.3, 0, 0}, {0, .3, 0}, {0, 0, 1}}]}, Axes -> True, 
  AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}]
y = Graphics3D[{Blue, Opacity[0.2
    ], Parallelepiped[{2, 0, 
     0}, {{.3, 0, 0}, {0, .3, 0}, {0, 0, 1}}]}, Axes -> True, 
  AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}]
z = Graphics3D[{Blue, Opacity[0.2
    ], Parallelepiped[{1, 2, 
     0}, {{.3, 0, 0}, {0, .3, 0}, {0, 0, 1}}]}, Axes -> True, 
  AxesEdge -> {{-1, -1}, {-1, -1}, {-1, -1}}]
Show[x, y, z, Boxed -> False, Ticks -> False, 
 PlotStyle -> Opacity[.5]]

I'm trying to give a generic indication of scale for the edges. Is it possible to add labels near each edge? Maybe with a curly bracket, or just a letter close to it? For example, the small side is $\delta$ and the big one is $\lambda$.

$\endgroup$
2
  • 1
    $\begingroup$ I'm a little uncertain. You want labels next each box appearing along an edge for each dimension? You mention axes, whose scales could be changed (but why change them?) and whose scales can be given arbitrary descriptions with custom Ticks and AxesLabel options. So do you want your labels to appear on the axes or near each box? $\endgroup$
    – Michael E2
    Commented Apr 10, 2022 at 15:53
  • $\begingroup$ I see, you are right, I will edit the question. I would like the labels to appear near each box, not on the axes. $\endgroup$
    – ibr_
    Commented Apr 10, 2022 at 16:01

1 Answer 1

2
$\begingroup$

One quick and dirty way is to add text halfway onto the edges $x+v_i$ of the Parallelepiped, here using a new Method defined for this purpose LabeledParallelepiped:

LabeledParallelepiped[x_,vi_,lables_,styles_]:=Module[{l,p},
  l=MapThread[Text[#1,x+0.5*#2]&,{lables,vi}];
  p=Flatten[{styles,Parallelepiped[x,vi]}];
  Graphics3D[{p,Black,l}]
]

x=LabeledParallelepiped[{0,0,0},{{.3,0,0},{0,.3,0},{0,0,1}},{"\[Delta]","\[Beta]","\[Lambda]"},{Blue,Opacity[0.2]}];
y=LabeledParallelepiped[{2,0,0},{{.3,0,0},{0,.3,0},{0,0,1}},{"\[Delta]","\[Beta]","\[Lambda]"},{Blue,Opacity[0.2]}];
z=LabeledParallelepiped[{1,2,0},{{.3,0,0},{0,.3,0},{0,0,1}},{"\[Delta]","\[Beta]","\[Lambda]"},{Blue,Opacity[0.2]}];

Show[x,y,z,Boxed->False,Ticks->False,Axes->True,AxesEdge->{{-1,-1},{-1,-1},{-1,-1}}]

which generates

Blocks

This is arguably not the nicest looking plot/diagram for the intended visualization but improvements would probably require additional parameters (like specifying the edge onto which a label should be placed, an offset (see e.g. the Offset option for Text) or even distance markers (like curly brackets or lines). But the present solution might be a good starting point.

$\endgroup$
1
  • $\begingroup$ It does the job! Thanks! $\endgroup$
    – ibr_
    Commented Apr 12, 2022 at 18:42

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.