# Labelling Vertices of a GraphicsComplex

I cannot figure out how to label the vertices of a GraphicsComplex, for example

Graphics3D[
GraphicsComplex[{{1, -1, 1}, {0, 0, 0}, {1, 1, 1}, {0, 0, 2}, {-1, 0,1}},
{Polygon[{2, 4, 5}], Polygon[{1, 3, 4}], Polygon[{1, 2, 3}]}]]


I've seen that this can be done for Graph and GraphPlot using VertexLabelling, but as far as I know, there isn't a similar option for GraphicsComplex.

• You've seen Text[]? GraphicsComplex[pts, Text[#, #] & /@ pts] Aug 22, 2015 at 0:35

Expanding on comment from Guess who it is, I think he pretty much had it nailed but instead of mapping onto pts I believe you need to use Range[Length[pts]].

GraphicsComplex will use the point number to indicate the position of the graphic object.

With[
{
pts = {{1, -1, 1}, {0, 0, 0}, {1, 1, 1}, {0, 0, 2}, {-1, 0, 1}}
},
Graphics3D[{
Opacity[0.5],
GraphicsComplex[pts,
{
Red, Polygon[{2, 4, 5}],
Blue, Polygon[{1, 3, 4}],
Green, Polygon[{1, 2, 3}],
}
],
Opacity[1],
Black,
GraphicsComplex[pts,
Text[Style[ToString[#], Background -> White, 16], #] &
/@ Range[Length[pts]]
]
}]
]


This makes a plot that looks like

You can also post-process the Graphics3D output to add the labels:

g0 = Graphics3D[GraphicsComplex[{{1, -1, 1}, {0, 0, 0}, {1, 1, 1}, {0, 0, 2}, {-1, 0, 1}},
{Polygon[{2, 4, 5}], Polygon[{1, 3, 4}], Polygon[{1, 2, 3}]}]];

Insert[g0, Text[Style[#, 24, Background -> Yellow], #] & /@
Range[Length @ g0[[1, 1]]], {1, 2, 1}]