AnnotationKeys[obj]
列出可用于对象 obj 的所有注释键.
AnnotationKeys[{obj,itemspec}]
列出在 obj 中由 itemspec 指定的项可用的所有注释键.
AnnotationKeys
AnnotationKeys[obj]
列出可用于对象 obj 的所有注释键.
AnnotationKeys[{obj,itemspec}]
列出在 obj 中由 itemspec 指定的项可用的所有注释键.
更多信息
- 通常用于提取与对象以及对象中的项关联的注释中的名称.
- AnnotationKeys 给出对象及其项的 key->value 注释中所有名称 keys 的列表.
- 带有注释的可能对象包括:
-
Audio 带有时间和时长的音频 BoundaryMeshRegion 带单元的边界网格 CSGRegion 几何区域 Graph 带顶点和边的图 MeshRegion 带单元的网格区域 - 每个对象 obj 的项规范 itemspec 在其参考页面中给出.
- 与对象 obj 关联的选项名称是 obj 的标准注释,但 AnnotationRules 除外.
范例
打开所有单元 关闭所有单元基本范例 (3)
g = ExampleData[{"NetworkGraph", "FlorentineFamilies"}]AnnotationKeys[g]AnnotationKeys[{g, "Medici"}]AnnotationKeys[{g, "Medici""Ridolfi"}]测试维度为1的单元中是否存在 MeshCellMarker 注释:
mr = MengerMesh[2, MeshCellMarker -> {{1, 1} -> 1, {1, 2} -> 2, {1, 3} -> 3}]MemberQ[AnnotationKeys[{mr, 1}], MeshCellMarker]AnnotationValue[{mr, {1, 1}}, MeshCellMarker]自动计算 Audio 对象的注释:
a = AudioAnnotate[Import["ExampleData/rule30.wav"], "Loud"];AnnotationKeys[a]AnnotationValue[a, "Loud"]范围 (8)
图和网络 (6)
将 AnnotationKeys 应用于顶点:
Graph[{Annotation[1, {VertexWeight -> 4, "Material" -> "Wood"}], 2, 3}, {12, 23, 31}]AnnotationKeys[{%, 1}]Graph[{1, 2, 3}, {Annotation[12, EdgeLabels -> "hello"], 23, 31}]AnnotationKeys[{%, 12}]AnnotationKeys 适用于无向图:
CycleGraph[5, VertexShapeFunction -> "Name"];AnnotationKeys[{[image], 12}]CycleGraph[5, DirectedEdges -> True, EdgeStyle -> Arrowheads[Small], VertexShapeFunction -> "Name"];AnnotationKeys[{[image], 12}]Module[{g},
g = Graph[Range[5], {12, 15, 23, 34, 45, 45, 45}, VertexCoordinates -> GraphEmbedding[CycleGraph[5]], VertexShapeFunction -> "Name", PerformanceGoal -> "Quality"];
MapThread[(AnnotationValue[{g, #1}, EdgeStyle] = #2)&, {EdgeList[g], {Gray, Blue, Red, Green, Brown, Brown, Brown}}];
g]AnnotationKeys[{%, 34}]Module[{g},
g = Graph[Range[5], {12, 15, 23, 34, 45}, VertexCoordinates -> GraphEmbedding[CycleGraph[5]], VertexShapeFunction -> "Name", PerformanceGoal -> "Quality"];
MapThread[(AnnotationValue[{g, #1}, EdgeStyle] = #2)&, {EdgeList[g], {Gray, Blue, Red, Green, Brown}}];
g]AnnotationKeys[{%, 15}]With[{g = CycleGraph[5], w = 0.3Range[5],
pl = {Right, Above, Above, Right, Above} /. {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]]];AnnotationKeys[{[image], 12}]区域 (2)
AnnotationKeys 适用于 CSGRegion 对象:
CSGRegion["Union", {Ball[], Cuboid[]}]AnnotationKeys[%]CSGRegion["Union", {Ball[], Cuboid[]}]AnnotationKeys[{%, {1}}]AnnotationKeys 返回标准的和用户定义的注释键:
CSGRegion["Union", {Annotation[Ball[], "Material" -> "Wood"], Cuboid[]}]AnnotationKeys[{%, {1}}]属性和关系 (6)
使用 Annotation 作为包装,在 Graph 之类的函数中指定注释:
Graph[{Annotation[1, {VertexSize -> Medium, VertexStyle -> Red}], 2, 3}, {12, 23, 31}]使用 AnnotationValue 提取值:
g = CompleteGraph[4, VertexStyle -> {1 -> Red}, VertexSize -> Small]AnnotationValue[{g, 1}, VertexStyle]对于未定义的注释,返回值 $Failed:
AnnotationValue[{g, 1}, "foo"]MemberQ[AnnotationKeys[{g, 1}], "foo"]使用 AnnotationValue 在图中设置注释:
g = CompleteGraph[4]AnnotationValue[{g, 1}, VertexSize] = Small;g使用 AnnotationValue 取消图中的注释:
g = CompleteGraph[4, VertexSize -> {1 -> Small}]AnnotationValue[{g, 1}, VertexSize]=.;g使用 Annotate 在新图中设置注释:
g = CompleteGraph[4]Annotate[{g, 1}, VertexSize -> Small]g使用 AnnotationDelete 删除注释而不更改原始图:
g = CompleteGraph[4, VertexSize -> {1 -> Small}]AnnotationDelete[{g, 1}, VertexSize]g文本
Wolfram Research (2020),AnnotationKeys,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AnnotationKeys.html (更新于 2025 年).
CMS
Wolfram 语言. 2020. "AnnotationKeys." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/AnnotationKeys.html.
APA
Wolfram 语言. (2020). AnnotationKeys. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AnnotationKeys.html 年
BibTeX
@misc{reference.wolfram_2026_annotationkeys, author="Wolfram Research", title="{AnnotationKeys}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/AnnotationKeys.html}", note=[Accessed: 18-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_annotationkeys, organization={Wolfram Research}, title={AnnotationKeys}, year={2025}, url={https://reference.wolfram.com/language/ref/AnnotationKeys.html}, note=[Accessed: 18-August-2026]}