GraphicsComplex[{pt1,pt2,…},data]
represents a graphics complex in which coordinates given as integers i in graphics primitives in data are taken to be pti.
GraphicsComplex
GraphicsComplex[{pt1,pt2,…},data]
represents a graphics complex in which coordinates given as integers i in graphics primitives in data are taken to be pti.
Details and Options
- GraphicsComplex works in both 2D and 3D.
- GraphicsComplex[{pt1,pt2,…},data] effectively replaces integers i that appear as coordinates in data by the corresponding pti.
- GraphicsComplex provides a convenient way to build up meshes or simplicial complexes in which vertices of polygons are shared.
- GraphicsComplex is treated like a single primitive in Graphics and Graphics3D.
- In GraphicsComplex[pts,data], data can be any nested list of graphics primitives and directives.
- The following options can be given:
-
ContentSelectable Automatic whether to allow contents to be selected VertexColors Automatic vertex colors corresponding to each pti VertexNormals Automatic vertex normals corresponding to each pti VertexTextureCoordinates None vertex texture coordinates for each pti - GraphicsComplex[{pt1,pt2,…},data,VertexColors->{c1,c2,…}] replaces Polygon[{i,j,…}] by Polygon[{pti,ptj,…},VertexColors->{ci,cj,…}].
- The VertexNormals and VertexTextureCoordinates option works the same way.
- Normal[GraphicsComplex[pts,data]] substitutes coordinates to give an ordinary list of graphics primitives and directives.
Examples
open all close allBasic Examples (3)
v = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};{Graphics[GraphicsComplex[v, Polygon[{1, 2, 3, 4}]]], Graphics[GraphicsComplex[v, Line[{1, 2, 3, 4, 1}]]]}v = {{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}};i = {{1, 2, 5}, {2, 3, 5}, {3, 4, 5}, {4, 1, 5}};{Graphics3D[{Opacity[.8], Yellow, GraphicsComplex[v, Polygon[i]]}], Graphics3D[{Thick, GraphicsComplex[v, Line[i]]}]}Use built-in PolyhedronData:
v = PolyhedronData["Dodecahedron", "Vertices"];Short[i = PolyhedronData["Dodecahedron", "FaceIndices"]]Graphics3D /@ {
{Yellow, GraphicsComplex[v, Polygon[i]]},
{Thick, GraphicsComplex[v, Line[i]]}}Do the same using PolyhedronData property annotations:
Graphics3D /@ {
{Yellow, PolyhedronData["Dodecahedron", "GraphicsComplex"]},
{Thick, PolyhedronData["Dodecahedron", "Edges", "GraphicsComplex"]}}Scope (3)
The coordinate data for any primitive can come from a GraphicsComplex:
p = {{0, 0}, {2, 0}, {2, 2}, {0, 2}};{Graphics[GraphicsComplex[p, Table[Circle[i], {i, 4}]]], Graphics[GraphicsComplex[p, Table[Rectangle[i], {i, 4}]]]}{Graphics[GraphicsComplex[p, Line[{1, 2, 3, 4, 1}]]], Graphics[GraphicsComplex[p, Polygon[{1, 2, 3, 4}]]]}p = {{0, 0, 0}, {2, 0, 1}, {2, 2, 1}, {0, 2, 0}};{Graphics3D[GraphicsComplex[p, Table[Sphere[i], {i, 4}]]], Graphics3D[GraphicsComplex[p, Table[Cuboid[i], {i, 4}]]]}{Graphics3D[GraphicsComplex[p, Line[{1, 2, 3, 4, 1}]]], Graphics3D[GraphicsComplex[p, Polygon[{1, 2, 3, 4}]]]}Mixing directives and primitives within a GraphicsComplex:
v = Table[15{Cos[t], Sin[t]}, {t, 0, 4Pi, 4Pi / 5}];Graphics[GraphicsComplex[v, {Green, Thick, Line[{1, 2, 3, 4, 5, 6}], PointSize[Large], Red, Point[{1, 2, 3, 4, 5}]}]]Options (7)
ContentSelectable (3)
No individual object is selectable; the graphics complex appears as one object:
Graphics[{Blue, Disk[{-1.5, .5}, .5], Pink, GraphicsComplex[{{0, .5}, {1, 0}}, {Disk[1, .5], Rectangle[2]}]}, ContentSelectable -> False]Allow the individual objects in the graphics complex to be selectable by a single click:
Graphics[{Blue, Disk[{-1.5, .5}, .5], Pink, GraphicsComplex[{{0, .5}, {1, 0}}, {Disk[1, .5], Rectangle[2]}]}, ContentSelectable -> True]The first click selects the whole complex, and subsequent clicks select individual objects:
Graphics[{Blue, Disk[{-1.5, .5}, .5], Pink, GraphicsComplex[{{0, .5}, {1, 0}}, {Disk[1, .5], Rectangle[2]}]}, ContentSelectable -> Automatic]VertexColors (2)
Specify colors for each vertex:
Graphics[GraphicsComplex[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, Polygon[{1, 2, 3}], VertexColors -> {Red, Green, Blue}]]Specify vertex colors for 3D polygons:
Graphics3D[GraphicsComplex[{{1, 0, 0}, {1, 1, 1}, {0, 0, 1}}, Polygon[{1, 2, 3}], VertexColors -> {Red, Green, Blue}]]VertexNormals (1)
Define vertices and face indices of a cylindrical model:
vl = Join[Table[{Cos[2π i / 20], Sin[2π i / 20], 0}, {i, 20}], Table[{Cos[2π i / 20], Sin[2π i / 20], 2}, {i, 20}]];il = Table[{i, Mod[i + 1, 20, 1], Mod[i + 21, 20, 21], i + 20}, {i, 1, 20}];Without surface normals, the shading is constant or flat for each polygon face:
Graphics3D[{Yellow, EdgeForm[], GraphicsComplex[vl, Polygon[il]]}]With surface normals, the shading is interpolated or smooth across each polygon face:
Graphics3D[{Yellow, EdgeForm[], GraphicsComplex[vl, Polygon[il], VertexNormals -> vl]}]VertexTextureCoordinates (1)
Texture mapping with 2D polygons:
Graphics[{Texture[ExampleData[{"TestImage", "Apples"}]], GraphicsComplex[{{-1, 0}, {1, 0}, {0, Sqrt[3]}}, Polygon[{1, 2, 3}], VertexTextureCoordinates -> {{0, 0}, {1, 0}, {.5, 1}}]}]Texture mapping with 3D polygons:
Graphics3D[{Texture[ExampleData[{"TestImage", "Apples"}]], GraphicsComplex[{{0, 0, 0}, {1, 1, 0}, {0, 1, 1}}, Polygon[{1, 2, 3}], VertexTextureCoordinates -> {{0, 0}, {1, 0}, {.5, 1}}]}]Applications (2)
Most surface and region plots produce GraphicsComplex:
ParametricPlot[{r Cos[θ], r Sin[θ]}, {r, 1, 2}, {θ, 0, 2Pi / 3}, PlotRange -> All, Mesh -> 15]You can use GraphicsComplex to transform the coordinates in this simple rotation:
% /. GraphicsComplex[p_List, rest__] :> GraphicsComplex[RotationTransform[Pi / 3][p], rest]The same idea applies to 3D surfaces:
Plot3D[Exp[-3x ^ 2 - y ^ 2], {x, -2, 2}, {y, -2, 2}, Mesh -> None, PlotRange -> All]% /. GraphicsComplex[p_List, rest__] :> GraphicsComplex[RotationTransform[Pi / 4, {0, 0, 1}][p], rest]Properties & Relations (4)
Set up a graphics complex with shared coordinates:
g = GraphicsComplex[{{0, 0}, {Sqrt[3], Sqrt[3] / 2}}, {Point[1], Line[{1, 2}]}];Applying Normal will split a complex into primitives with duplicated coordinates:
Normal[g]Both forms produce the same image:
{Graphics[g], Graphics[Normal[g]]}Graphics complexes can be built up from integrated PolyhedronData:
v = PolyhedronData["SnubCube", "VertexCoordinates"];i = PolyhedronData["SnubCube", "FaceIndices"];Graphics3D[GraphicsComplex[v, Polygon[i]]]Or, get a graphics complex directly:
g = PolyhedronData["SnubCube", "GraphicsComplex"];Graphics3D[g]Head[g]ExampleData contains a number of 3D graphics complex models:
Short[ExampleData["Geometry3D"]]g = ExampleData[{"Geometry3D", "UtahTeapot"}, "GraphicsComplex"];Graphics3D[g]Many Import formats produce GraphicsComplex:
g = Import[ "http://exampledata.wolfram.com/bunny.noff.gz", "GraphicsComplex"];Graphics3D[{EdgeForm[], g}, ViewPoint -> Top]Head[g]In this case the surface has about 35000 vertices:
Length[First[g]]Neat Examples (2)
A random selection of index coordinates:
p = Table[{Cos[2Pi / 70 k], Sin[2Pi / 70 k]}, {k, 70}];Graphics[GraphicsComplex[p, Polygon[RandomSample[Range[70], 70]]]]p = Flatten[Table[{Cos[2Pi / 25 k] Sin[Pi / 25 l], Sin[2Pi / 25 k] Sin[Pi / 25 l], Cos[Pi / 25 l]}, {k, 25}, {l, 25}], 1];Graphics3D[{Opacity[.8], EdgeForm[Opacity[.3]], GraphicsComplex[p, Polygon[RandomInteger[{1, 625}, {100, 3}]], VertexColors -> Table[Hue[RandomReal[]], {625}]]}, Lighting -> "Neutral"]g = ExampleData[{"Geometry3D", "Cow"}, "GraphicsComplex"];Grid@Table[With[{f = ColorData[RandomChoice[ColorData["Gradients"]]]}, Graphics3D[{EdgeForm[], g /. GraphicsComplex[v_, r__] :> GraphicsComplex[v, r, VertexColors -> ({Specularity[White, 30], f[#[[1]] + .5]}& /@ v)]}, Lighting -> "Neutral", Boxed -> False, Background -> GrayLevel[.15], ImageSize -> 150]], {3}, {3}]See Also
Related Guides
History
Text
Wolfram Research (2007), GraphicsComplex, Wolfram Language function, https://reference.wolfram.com/language/ref/GraphicsComplex.html.
CMS
Wolfram Language. 2007. "GraphicsComplex." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/GraphicsComplex.html.
APA
Wolfram Language. (2007). GraphicsComplex. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/GraphicsComplex.html
BibTeX
@misc{reference.wolfram_2026_graphicscomplex, author="Wolfram Research", title="{GraphicsComplex}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/GraphicsComplex.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_graphicscomplex, organization={Wolfram Research}, title={GraphicsComplex}, year={2007}, url={https://reference.wolfram.com/language/ref/GraphicsComplex.html}, note=[Accessed: 12-June-2026]}