AnnotationValue[obj,key]
gives the annotation value associated with key for the object obj.
AnnotationValue[{obj,itemspec},key]
gives the annotation value associated with key for items specified by itemspec in obj.
AnnotationValue
AnnotationValue[obj,key]
gives the annotation value associated with key for the object obj.
AnnotationValue[{obj,itemspec},key]
gives the annotation value associated with key for items specified by itemspec in obj.
Details
- Typically used to extract and manipulate values in annotations associated to an object or an item in an object.
- AnnotationValue gives the value value in key->value annotations for an object and its items.
- 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.
- Missing is returned when a name requested in AnnotationValue is not found.
- AnnotationValue[{obj,itemspec},key] returns unevaluated for the tag key without value.
- AnnotationValue[…,key]=val can be used to modify the annotation value.
Examples
open all close allBasic Examples (3)
Generate a complete graph with annotations:
g = CompleteGraph[4, VertexLabels -> {1 -> "one"}]Retrieve the annotation value associated with an annotation name:
AnnotationValue[g, VertexLabels]AnnotationValue[{g, 1}, VertexLabels] = "two";gAnnotationValue[{g, 1}, VertexLabels]=.;gGet intrinsic MeshCellMeasure annotations for cells in a mesh:
mr = MengerMesh[2]AnnotationValue[{mr, {2, 1}}, MeshCellMeasure]Automatically compute annotations for an Audio object:
a = AudioAnnotate[Import["ExampleData/rule30.wav"], "Loud"];Retrieve annotations for louder intervals:
AnnotationValue[a, "Loud"]Scope (18)
Graphs & Networks (13)
Graph annotations (7)
Retrieve several properties from a vertex:
g = CompleteGraph[4, VertexStyle -> {1 -> Blue}, VertexLabels -> {1 -> "one"}, EdgeStyle -> {12 -> Blue}, EdgeLabels -> {12 -> "hello"}]AnnotationValue[{g, 1}, {VertexStyle, VertexLabels}]AnnotationValue[{g, 12}, {EdgeStyle, EdgeLabels}]AnnotationValue[{g, 24}, {EdgeStyle, EdgeLabels}] = {Red, "bye"};gUnset annotations for vertices:
g = CompleteGraph[4, VertexStyle -> {1 -> Blue}, VertexLabels -> {1 -> "one"}, EdgeStyle -> {12 -> Blue}, EdgeLabels -> {12 -> "hello"}]AnnotationValue[{g, 1}, VertexLabels]=.;gAnnotationValue[{g, 12}, EdgeLabels]=.;gAnnotationValue works with undirected graphs:
AnnotationValue[{[image], 12}, EdgeStyle]AnnotationValue[{[image], 12}, EdgeStyle]AnnotationValue[{[image], 12}, EdgeStyle]AnnotationValue[{[image], 12}, EdgeStyle]AnnotationValue[{[image], 12}, EdgeWeight]Vertex annotations (3)
Standard vertex annotations include VertexStyle:
g = CompleteGraph[4, VertexSize -> Small]AnnotationValue[{g, 4}, VertexStyle] = Red;gAnnotationValue[{g, 1}, VertexLabels] = "one";gAnnotationValue[{g, 1}, VertexSize] = Large;gAnnotationValue[{g, 1}, VertexShape] = [image];gAnnotationValue[{g, 2}, VertexShapeFunction] = "Square";gNon-visual annotations include VertexWeight:
AnnotationValue[{g, 1}, VertexWeight] = 100;AnnotationValue[{g, 1}, VertexWeight]g = CompleteGraph[4];AnnotationValue[{g, 2}, "Material"] = "Wood";AnnotationValue[{g, 2}, "Material"]Set an annotation value for vertex 1:
g = CompleteGraph[4]AnnotationValue[{g, 1}, VertexLabels] = "vertex";gRetrieve the annotation value for vertex 1:
AnnotationValue[{%, 1}, VertexLabels]Edge annotations (3)
Standard edge annotations include EdgeStyle:
g = CompleteGraph[4]AnnotationValue[{g, 12}, EdgeStyle] = Brown;gAnnotationValue[{g, 12}, EdgeLabels] = 12;gAnnotationValue[{g, 34}, EdgeShapeFunction] = {"HalfFilledDoubleArrow", "ArrowSize" -> .2};gNon-visual annotations include EdgeWeight:
AnnotationValue[{g, 12}, EdgeWeight] = 42;AnnotationValue[{g, 12}, EdgeWeight]g = CompleteGraph[4];AnnotationValue[{g, 24}, "Resistance"] = 50.;AnnotationValue[{g, 24}, "Resistance"]Set an annotation value for the edge 12:
g = CompleteGraph[4]AnnotationValue[{g, 12}, EdgeLabels] = "edge";gRetrieve the annotation value for the edge 12:
AnnotationValue[{g, 12}, EdgeLabels]Regions (3)
Retrieve an annotation from a CSGRegion:
CSGRegion["Union", {Style[Ball[], Red], Style[Cuboid[], Blue]}]AnnotationValue[{%, {1}}, "CSGRegionStyle"]csg = CSGRegion["Union", {Ball[], Cuboid[]}]AnnotationValue[csg, "CSGRegionStyle"] = Red;csgcsg = CSGRegion["Union", {Style[Ball[], Red], Style[Cuboid[], Blue]}]AnnotationValue[{csg, {1}}, "CSGRegionStyle"]=.;csgAudio (2)
Annotate an Audio object:
a = Import["ExampleData/rule30.wav"];
a = Annotate[a, "Label" -> {.3 -> "val1", .6 -> "val2"}]Retrieve the annotation using AnnotationValue:
AnnotationValue[a, "Label"]Annotate an Audio object using AudioAnnotate:
a = Import["ExampleData/rule30.wav"];
a = AudioAnnotate[a, {"Loud", "Transients"}]Retrieve multiple annotations using AnnotationValue:
AnnotationValue[a, {"Loud", "Transients"}]//ColumnApplications (5)
Use Do to set several annotation values:
g = CompleteGraph[8, VertexSize -> Medium]Do[AnnotationValue[{g, v}, VertexStyle] = StandardGray, {v, {4, 5, 6, 7, 8}}]gOr different annotation values for different items:
Do[AnnotationValue[{g, v[[1]]}, VertexStyle] = v[[2]], {v, {{1, Red}, {2, Green}, {3, Blue}, {6, Orange}}}]gUse Table to build a list of annotation values:
Table[AnnotationValue[{g, v}, VertexStyle], {v, VertexList[g]}]GraphicsGrid[{Graphics[{#, Disk[]}]& /@ %}]g = CompleteGraph[5]Do[AnnotationValue[{g, e}, EdgeWeight] = RandomReal[], {e, EdgeList[g]}]Table[AnnotationValue[{g, e}, EdgeWeight], {e, EdgeList[g]}]{min, max} = {Min[#], Max[#]}&@%Set the edge thickness to reflect the edge weight:
Do[AnnotationValue[{g, e}, EdgeStyle] = AbsoluteThickness[Rescale[AnnotationValue[{g, e}, EdgeWeight], {min, max}, {1, 4}]], {e, EdgeList[g]}]gHighlight a path and mark the start point and endpoint:
g = CompleteGraph[5]path = {3, 4, 1, 5, 2};Highlight by setting edge style along the path and vertex labels for start point and endpoint:
Do[AnnotationValue[{g, e}, EdgeStyle] = Red, {e, EdgeList[PathGraph[path]]}]AnnotationValue[{g, path[[1]]}, VertexLabels] = "Start";
AnnotationValue[{g, path[[-1]]}, VertexLabels] = "End";gDynamically highlight the edges in the order given by EdgeList:
Dynamic[g, Initialization :> (g = GridGraph[{5, 5}])]Do[AnnotationValue[{g, e}, EdgeStyle] = Directive[Thick, Blue]; Pause[0.2], {e, EdgeList[g]}]//AbsoluteTimingDynamically visualize breadth-first search:
Dynamic[g, Initialization :> (g = CompleteKaryTree[3, 3, ImageSize -> Medium, VertexSize -> Medium])]BreadthFirstScan[g, {"DiscoverVertex" -> ((AnnotationValue[{g, #}, VertexStyle] = Red;Pause[0.25]) &), "FrontierEdge" -> ((AnnotationValue[{g, #}, EdgeStyle] = Blue;Pause[0.25]) &) }];Properties & Relations (5)
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}]AnnotationValue returns $Failed for undefined annotations:
AnnotationValue[{CompleteGraph[4], 1}, VertexWeight]Use 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 Annotate to set an annotation without changing the original:
g = CompleteGraph[4]Annotate[{g, 1}, VertexSize -> Medium]The original graph is unchanged:
gUse 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 (2)
AnnotationValue returns $Failed for undefined annotations:
g = CompleteGraph[4, VertexSize -> {1 -> Small}]AnnotationValue[{g, 1}, vertexSize]Use AnnotationKeys to test for the presence of an annotation:
MemberQ[AnnotationKeys[{g, 1}], VertexSize]MemberQ[AnnotationKeys[{g, 1}], vertexSize]AnnotationValue may return $Failed even when an annotation value exists:
g = Graph[{Annotation[1, "Result" -> $Failed], 2, 3}, {12, 23, 31}]AnnotationValue[{g, 1}, "Result"]Use AnnotationKeys to check for actual annotation values:
MemberQ[AnnotationKeys[{g, 1}], "Result"]Related Guides
Text
Wolfram Research (2020), AnnotationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/AnnotationValue.html (updated 2025).
CMS
Wolfram Language. 2020. "AnnotationValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2025. https://reference.wolfram.com/language/ref/AnnotationValue.html.
APA
Wolfram Language. (2020). AnnotationValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/AnnotationValue.html
BibTeX
@misc{reference.wolfram_2026_annotationvalue, author="Wolfram Research", title="{AnnotationValue}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/AnnotationValue.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_annotationvalue, organization={Wolfram Research}, title={AnnotationValue}, year={2025}, url={https://reference.wolfram.com/language/ref/AnnotationValue.html}, note=[Accessed: 12-June-2026]}