is an option and annotation of MeshRegion, BoundaryMeshRegion, and related functions that specifies styles to use for mesh cells.
MeshCellStyle
is an option and annotation of MeshRegion, BoundaryMeshRegion, and related functions that specifies styles to use for mesh cells.
Details
- The following option settings can be used:
-
Automatic use automatic setting for style None render mesh cells with perfect transparency style use style for all mesh cells {cellspec1->style1,…} use stylei for mesh cell cellspeci - Mesh cells with no explicit mesh cell style are taken to use the automatic style.
- The wrapper Style[cellspec,style] is equivalent to Annotation[cellspec,MeshCellStylestyle] and can be used when creating mesh regions in functions such as MeshRegion, BoundaryMeshRegion, etc.
- To specify multiple style directives, use Directive[style1,style2,…].
- The cell specification cellspec follows the standard form described for MeshRegion and BoundaryMeshRegion.
- Style and other specifications are effectively applied in the order MeshCellStyle, Style and other wrappers, and MeshCellShapeFunction, with later specifications overriding earlier ones.
Examples
open all close allBasic Examples (3)
Style all 1D cells red and all 0D cells green:
MeshRegion[{{0, 0}, {1, 0}, {2, 1 / 2}, {2, -1 / 2}}, {Line[{1, 2}], Line[{2, 3}], Line[{3, 4}], Line[{4, 2}]},
MeshCellStyle -> {{1, All} -> Red, {0, All} -> Green}]Style all 2D cells transparent orange, 1D elements red, and 0D elements green:
MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, -1, 0}, {1, 0, 0}, {0, 1, 0}}, {Triangle[{1, 2, 3}], Triangle[{1, 2, 4}], Triangle[{1, 2, 5}]}, MeshCellStyle -> {{2, All} -> Opacity[0.5, Orange], {1, All} -> Red, {0, All} -> Directive[PointSize[Medium], Green]}]Style all 2D cells transparent orange:
MeshRegion[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}, {Tetrahedron[{1, 2, 3, 5}], Tetrahedron[{1, 3, 4, 5}]}, MeshCellStyle -> {{2, All} -> Opacity[0.5, Orange]}]Scope (10)
Style all 1D cells red and all 0D cells green:
MeshRegion[{{0, 0}, {1, 0}, {2, 1 / 2}, {2, -1 / 2}}, {Line[{1, 2}], Line[{2, 3}], Line[{3, 4}], Line[{4, 2}]},
MeshCellStyle -> {{1, All} -> Red, {0, All} -> Green}]Style all 2D cells transparent orange, 1D elements red, and 0D elements green:
MeshRegion[{{0, 0, 0}, {0, 0, 1}, {0, -1, 0}, {1, 0, 0}, {0, 1, 0}}, {Triangle[{1, 2, 3}], Triangle[{1, 2, 4}], Triangle[{1, 2, 5}]}, MeshCellStyle -> {{2, All} -> Opacity[0.5, Orange], {1, All} -> Red, {0, All} -> Directive[PointSize[Medium], Green]}]Style all 2D cells transparent orange:
MeshRegion[{{0, 0, 0}, {2, 0, 0}, {2, 2, 0}, {0, 2, 0}, {1, 1, 2}}, {Tetrahedron[{1, 2, 3, 5}], Tetrahedron[{1, 3, 4, 5}]}, MeshCellStyle -> {{2, All} -> Opacity[0.5, Orange]}]Individual cells can be styled using their cell index:
MeshRegion[{{0}, {1}, {2}}, Line[{{1, 2, 3}}], MeshCellStyle -> {{1, 1} -> {Thick, Red}, {1, 2} -> {Dashed, Green}}]MeshRegion[{{0}, {1}, {2}}, Line[{{1, 2, 3}}], MeshCellStyle -> {Line[{1, 2}] -> {Thick, Red}, Line[{2, 3}] -> {Dashed, Green}}]All can be used to specify all cells:
BoundaryMeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}], MeshCellStyle -> {All -> Red}]By default, all cells are styled:
BoundaryMeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}], MeshCellStyle -> Red]Style all cells of a given dimension:
BoundaryMeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}], MeshCellStyle -> {0 -> {PointSize[Large], Green}, 1 -> Red}]Specify a list of cell indices to style:
BoundaryMeshRegion[{{0, 0}, {1, 0}, {0, 1}}, Line[{1, 2, 3, 1}], MeshCellStyle -> {{{0, 1}, {1, 2}} -> Red}]Style cells whose dimensions match a pattern:
BoundaryMeshRegion[{{0, 0, 0}, {1, 0, 0}, {0, 1, 0}, {0, 0, 1}}, Polygon[{{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {1, 3, 4}}], MeshCellStyle -> {{0 | 1} -> Red}]Style cells whose indices match a pattern:
BoundaryMeshRegion[{{0, 0}, {3, 0}, {3, 3}, {0, 3}, {1, 1}, {2, 1}, {2, 2}, {1, 2}}, Line[{1, 2, 3, 4, 1}], Line[{5, 6, 7, 8, 5}], MeshCellStyle -> {{1, _ ? EvenQ} -> Red}]Style with graphics directives appropriate for the dimension of the components:
ℛ = BoundaryMeshRegion[{{0, 0, 0}, {4, 0, 0}, {0, 4, 0}, {0, 0, 4}}, Polygon[{{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {1, 3, 4}}], MeshCellStyle -> {0 -> {PointSize[Large], Green}, 1 -> {Dashed, Thick, Red}, 2 -> Opacity[0.7, Orange]}]Applications (1)
Style a polyhedron's faces by the number of vertices it has:
PolyhedronMesh[name_] :=
BoundaryMeshRegion[PolyhedronData[name, "Vertices"], Polygon[PolyhedronData[name, "FaceIndices"]]];PolyhedronMesh["Cuboctahedron"]Gather the faces with different numbers of vertices:
ColoredPolyhedron[name_String] :=
Module[{bmr = PolyhedronMesh[name], fl},
fl = GatherBy[MeshCells[bmr, 2], Length[First[#]]&];
BoundaryMeshRegion[MeshCoordinates[bmr], Table[Style[fl[[i]], ColorData[100, i]], {i, Length[fl]}]]
]Color the Archimedean polyhedra:
ColoredPolyhedron /@ PolyhedronData["Archimedean"]Related Guides
Text
Wolfram Research (2014), MeshCellStyle, Wolfram Language function, https://reference.wolfram.com/language/ref/MeshCellStyle.html (updated 2015).
CMS
Wolfram Language. 2014. "MeshCellStyle." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2015. https://reference.wolfram.com/language/ref/MeshCellStyle.html.
APA
Wolfram Language. (2014). MeshCellStyle. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/MeshCellStyle.html
BibTeX
@misc{reference.wolfram_2026_meshcellstyle, author="Wolfram Research", title="{MeshCellStyle}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/MeshCellStyle.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_meshcellstyle, organization={Wolfram Research}, title={MeshCellStyle}, year={2015}, url={https://reference.wolfram.com/language/ref/MeshCellStyle.html}, note=[Accessed: 12-June-2026]}