1
$\begingroup$

I have the following code to plot a 3d convex hull with 4 corners only.

P[0]={0,0,0};P[1]={1,0,0};P[2]={0,1,0};P[3]={0,0,1};P[4]={-1,-1,-1};P[5]={-1,0,-1};
P[6]={0,-1,-1};
R[1]=ConvexHullMesh[{P[0],P[1],P[2],P[3]}];
face[1]=MeshPrimitives[R[1], "Polygons"];
colors = Opacity[.5, #]& /@ { Green, Blue, Yellow,Red} ;
Graphics3D[{EdgeForm[{Thick, Red}], FaceForm[{Red,Green,Blue,Black}],Transpose@{colors , face[1]}}, 
 PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}, Axes -> True, 
 ImageSize -> Large, AxesOrigin -> {0, 0, 0}, 
 LabelStyle -> {12, Bold, Black}, 
 AxesStyle -> Thick, Boxed -> True,AxesLabel->{x,y,z},Epilog -> {Inset[Style["[1,3,2]", 20, Bold], {.2, .8}]}]

In the above plot, the corners are at (0,0,0),(1,0,0),(0,1,0) and (0,0,1). I want to label each corner (for a better view) by attaching the coordinate at the corners. How can it be done? So that when I rotate the 3d plot (using mouse) the labels stay attached to the points it denotes.

$\endgroup$
2
$\begingroup$

I did it with Callouts in a ListPointPlot3D combined with your original Graphics3D using Show:

P[0] = {0, 0, 0}; P[1] = {1, 0, 0}; P[2] = {0, 1, 0}; 
P[3] = {0, 0, 1}; P[4] = {-1, -1, -1}; P[5] = {-1, 0, -1};
P[6] = {0, -1, -1};
R[1] = ConvexHullMesh[{P[0], P[1], P[2], P[3]}];
face[1] = MeshPrimitives[R[1], "Polygons"];
colors = Opacity[.5, #] & /@ {Green, Blue, Yellow, Red};

Show[

 Graphics3D[{EdgeForm[{Thick, Red}], 
   FaceForm[{Red, Green, Blue, Black}], Transpose@{colors, face[1]}}, 
   PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}, Axes -> True, 
   ImageSize -> Large, AxesOrigin -> {0, 0, 0}, 
   LabelStyle -> {12, Bold, Black}, AxesStyle -> Thick, Boxed -> True, 
   AxesLabel -> {x, y, z}, 
   Epilog -> {Inset[Style["[1,3,2]", 20, Bold], {.2, .8}]}],

 (* Produce Callouts in a separate ListPointPlot3D *)
 ListPointPlot3D[
   MapThread[
     Callout[#1, ToString@#1, #2, 
       LabelStyle -> {Medium, Black, Background -> White}, 
       CalloutStyle -> White] &,
     {{P[0], P[1], P[2], P[3]}, {Left, Above, Right, Left}}
   ]
  ]
]

Graphics3D with callouts in separate plot

$\endgroup$
1
  • $\begingroup$ Thanks. But I face one problem when I try to rotate the plot using a mouse. The size shrinks and makes it clumsy. I tried to put ImageSize->Large put still the problem persists. (Btw I use Mathematica Online) $\endgroup$ – Epsilon Jun 6 '20 at 21:08

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.