Annotate
Details
- Typically used to store key->value pairs for an object or items in an object.
- Annotate returns the specified object with a new or modified annotation.
- Possible objects with items that can be annotated:
-
Audio time points and time intervals BoundaryMeshRegion mesh cells CSGRegion geometric regions Graph vertices and edges MeshRegion mesh cells - Item specification itemspec for each type of object is given in its reference page.
Examples
open all close allBasic Examples (3)
Specify a vertex or edge annotation:
g = CompleteGraph[4]Annotate[{g, 1}, VertexLabels -> "one"]Annotate[{g, 12}, EdgeStyle -> Red]Highlight boundary cells in a mesh:
Annotate[{MengerMesh[2], {1, "Boundary"}}, MeshCellStyle -> Red]Highlight a region within CSGRegion:
Annotate[{CSGRegion[{Ball[], Cuboid[]}], {2}}, "CSGRegionStyle" -> Red]Scope (17)
Graph & Networks (11)
Graph annotations (7)
CompleteGraph[4];Annotate[{[image], 1}, VertexSize -> Small]Annotate[{[image], 12}, EdgeLabels -> "hello"]Set several annotations for a vertex:
CompleteGraph[4, VertexSize -> Medium];Annotate[{[image], 1}, {VertexStyle -> Magenta, VertexLabels -> "hello"}]Annotate[{[image], 12}, {EdgeStyle -> Magenta, EdgeLabels -> "hello"}]Annotate works with undirected graphs:
CycleGraph[3];Annotate[{[image], 12}, {EdgeStyle -> Brown}]CycleGraph[3, DirectedEdges -> True, EdgeStyle -> Arrowheads[Small]];Annotate[{[image], 12}, {EdgeLabels -> "hello"}]Graph[{1, 2, 3}, {12, 23, 23, 23, 31}];Annotate[{[image], 12}, {EdgeStyle -> Brown}]Graph[{1, 2, 3}, {12, 23, 31}, EdgeStyle -> Arrowheads[0.08]];Annotate[{[image], 12}, {EdgeStyle -> Brown}]With[{g = CycleGraph[3], w = 0.3Range[3],
pl = {Above, Right, Right} /. {Right -> {1 / 2, {-0.4, 1 / 2}}, Above -> {1 / 2, {1 / 2, 0}}}},
Graph[VertexList[g], EdgeList[g], EdgeWeight -> w, VertexShapeFunction -> "Name", EdgeLabels -> Thread[EdgeList[g] -> MapThread[Placed, {w, pl}]], VertexCoordinates -> GraphEmbedding[g]]];Annotate[{[image], 12}, {EdgeStyle -> Dashed}]Vertex annotations (2)
Standard vertex annotations include VertexStyle:
g = CompleteGraph[4, VertexSize -> Medium]Annotate[{g, 4}, VertexStyle -> Red]Annotate[{g, 1}, VertexLabels -> "one"]Annotate[{g, 1}, VertexSize -> Tiny]Annotate[{g, 1}, VertexShape -> [image]]Annotate[{g, 2}, VertexShapeFunction -> "Square"]Non-visual annotations include VertexWeight:
Annotate[{g, 1}, VertexWeight -> 100]AnnotationValue[{%, 1}, VertexWeight]CompleteGraph[4];Annotate[{[image], 2}, "Material" -> "Wood"]AnnotationValue[{%, 2}, "Material"]Edge annotations (2)
Standard edge annotations include EdgeStyle:
g = CompleteGraph[4]Annotate[{g, 12}, EdgeStyle -> Brown]Annotate[{g, 12}, EdgeLabels -> 12]Annotate[{g, 34}, EdgeShapeFunction -> "HalfFilledDoubleArrow"]Non-visual annotations include EdgeWeight:
Annotate[{g, 12}, EdgeWeight -> 42]AnnotationValue[{%, 12}, EdgeWeight]CompleteGraph[4];Annotate[{[image], 24}, "Resistance" -> 50.]AnnotationValue[{%, 24}, "Resistance"]Regions (6)
BoundaryMeshRegion (2)
Annotate a point:
bmr = BoundaryMesh[Cube[]];Annotate[{bmr, {0, 7}}, MeshCellStyle -> {PointSize[Large], Red}]Annotate[{bmr, {1, 9}}, MeshCellStyle -> {Thick, Red}]Annotate[{bmr, {2, 6}}, MeshCellStyle -> {Red}]Annotate all mesh cells of specific dimension:
bmr = BoundaryMesh[Cube[]];Table[Annotate[{bmr, {d}}, MeshCellStyle -> Red], {d, {0, 1, 2}}]MeshRegion (2)
Annotate a point:
mr = MengerMesh[1];Annotate[{mr, {0, 7}}, MeshCellStyle -> {PointSize[Large], Red}]Annotate[{mr, {1, 2}}, MeshCellStyle -> {Thick, Red}]Annotate[{mr, {2, 1}}, MeshCellStyle -> {Red}]Annotate all mesh cells of specific dimension:
mr = MengerMesh[2];Table[Annotate[{mr, {d}}, MeshCellStyle -> Red], {d, {0, 1, 2}}]CSGRegion (2)
csg = CSGRegion["Union", {Ball[], Cuboid[]}]Annotate[csg, "CSGRegionStyle" -> Red]Annotate a child region within CSGRegion:
csg = CSGRegion["Union", {Ball[], Cuboid[]}]Annotate[{csg, {2}}, "CSGRegionStyle" -> Red]Applications (3)
Use Fold to apply Annotate repeatedly:
g = CycleGraph[8, VertexSize -> Large]Fold[Annotate[{#1, #2}, VertexStyle -> ColorData[45, #2]]&, g, Range[1, 5]]FoldList[Annotate[{#1, #2}, VertexStyle -> ColorData[45, #2]]&, g, Range[1, 6]]g = CompleteGraph[4]Temporarily highlight one vertex:
Annotate[{g, 1}, VertexSize -> Medium]Annotate[{g, 2}, VertexSize -> Medium]Highlight the edges visited during a breadth-first scan:
g = CompleteKaryTree[4, 3, DirectedEdges -> True]ListAnimate[Reap[BreadthFirstScan[g, {"FrontierEdge" -> (Sow[Annotate[{g, #}, EdgeStyle -> Red]]& )}]][[2, 1]], DefaultDuration -> Length[EdgeList[g]] / 2, SaveDefinitions -> True]Properties & Relations (6)
Use Annotation as a wrapper to specify annotations in functions such as Graph:
Graph[{Annotation[1, {VertexSize -> Medium, VertexStyle -> Red}], 2, 3}, {12, 23, 31}]Use AnnotationValue to extract values:
g = CompleteGraph[4, VertexStyle -> {1 -> Red}, VertexSize -> Small]AnnotationValue[{g, 1}, VertexStyle]For undefined annotations, the value $Failed is returned:
AnnotationValue[{g, 1}, "foo"]MemberQ[AnnotationKeys[{g, 1}], "foo"]Use AnnotationValue to set annotations in a graph:
g = CompleteGraph[4]AnnotationValue[{g, 1}, VertexSize] = Small;The original graph has changed:
gUse AnnotationValue to unset annotations in a graph:
g = CompleteGraph[4, VertexSize -> {1 -> Small}]AnnotationValue[{g, 1}, VertexSize]=.;The original graph has changed:
gUse AnnotationKeys to test for the presence of an annotation:
g = CompleteGraph[4, VertexLabels -> {1 -> one, 4 -> four}]MemberQ[AnnotationKeys[{g, 1}], VertexLabels]Generate a list of vertex label rules:
Cases[VertexList[g], v_ /; MemberQ[AnnotationKeys[{g, v}], VertexLabels] :> v -> AnnotationValue[{g, v}, VertexLabels]]Use AnnotationDelete to remove an annotation without changing the original:
g = CompleteGraph[4, VertexStyle -> {1 -> Red}, VertexSize -> Small]AnnotationDelete[{g, 1}, VertexStyle]The original graph is unchanged:
gPossible Issues (1)
AnnotationValue is typically faster than Annotate:
g = CycleGraph[1000];Timing@Do[AnnotationValue[{g, v}, VertexWeight] = RandomReal[], {v, VertexList[g]}]g = CycleGraph[1000];Timing@Do[g = Annotate[{g, v}, VertexWeight -> RandomReal[]], {v, VertexList[g]}]Related Guides
Text
Wolfram Research (2020), Annotate, Wolfram Language function, https://reference.wolfram.com/language/ref/Annotate.html (updated 2025).
CMS
Wolfram Language. 2020. "Annotate." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/Annotate.html.
APA
Wolfram Language. (2020). Annotate. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Annotate.html
BibTeX
@misc{reference.wolfram_2026_annotate, author="Wolfram Research", title="{Annotate}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/Annotate.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_annotate, organization={Wolfram Research}, title={Annotate}, year={2025}, url={https://reference.wolfram.com/language/ref/Annotate.html}, note=[Accessed: 12-June-2026]}