AnnotationDelete[obj]
删除对象 obj 的所有注释.
AnnotationDelete[{obj,itemspec}]
删除由 itemspec 指定的 obj 项的所有注释.
AnnotationDelete[spec,key]
删除由 spec 指定的注释 key.
AnnotationDelete
AnnotationDelete[obj]
删除对象 obj 的所有注释.
AnnotationDelete[{obj,itemspec}]
删除由 itemspec 指定的 obj 项的所有注释.
AnnotationDelete[spec,key]
删除由 spec 指定的注释 key.
更多信息
- 通常用于删除对象和对象中特定项的注释.
- AnnotationDelete[spec,key] 返回 spec 中指定的对象,其中注释 key 已被删除.
- 对于标准注释,AnnotationDelete 有效地将值重置为注释默认值.
- 带有可注释项的可能对象:
-
Audio 时间点和时间间隔 BoundaryMeshRegion 网格单元 CSGRegion 几何区域 Graph 顶点和边 MeshRegion 网格单元 - 每种对象类型的项规范 itemspec 在其参考页中给出.
范例
打开所有单元 关闭所有单元基本范例 (3)
g = CompleteGraph[4, VertexLabels -> {1 -> "here"}, EdgeStyle -> {12 -> Red}]{AnnotationDelete[{g, 1}, VertexLabels], AnnotationDelete[{g, 12}, EdgeStyle]}mr = MengerMesh[1, MeshCellStyle -> {{1, All} -> Red}, MeshCellLabel -> {0 -> "Index"}]{AnnotationDelete[{mr, {1, All}}, MeshCellStyle], AnnotationDelete[{mr, 0}, MeshCellLabel]}为 Audio 对象添加注释:
a = Import["ExampleData/rule30.wav"];res = AudioAnnotate[a, {"tag1" -> {.5 -> "v11", {1, 1.5} -> "v12"}, "tag2" -> {.1 -> "v21", {.7, 1.5} -> "v22"}}];AnnotationDelete[res, "tag1"]//AudioAnnotationLookup范围 (11)
图与网络 (7)
图注释 (5)
g = CompleteGraph[4, VertexStyle -> {1 -> Red}, VertexSize -> {1 -> Small}, EdgeStyle -> {12 -> Brown}, EdgeLabels -> {12 -> "hello"}]AnnotationDelete[{g, 1}, VertexStyle]AnnotationDelete[{g, 12}, EdgeLabels]AnnotationDelete[{g, 1}]AnnotationDelete[{g, 12}]CompleteGraph[4, VertexStyle -> {1 -> Red}, VertexSize -> {1 -> Small}, VertexLabels -> {1 -> "vertex"}];AnnotationDelete[{[image], 1}, {VertexLabels, VertexStyle}]WheelGraph[4, DirectedEdges -> True, EdgeStyle -> {_ -> Arrowheads[0.08], 12 -> Directive[Brown, Arrowheads[0.08]]}, EdgeLabels -> {12 -> "edge"}];AnnotationDelete[{[image], 12}, {EdgeStyle, EdgeLabels}]AnnotationDelete 适用于无向图:
CycleGraph[3, EdgeStyle -> {12 -> Brown}, EdgeLabels -> {12 -> "edge"}];AnnotationDelete[{[image], 12}, EdgeStyle]CycleGraph[3, DirectedEdges -> True, EdgeStyle -> {12 -> Directive[Arrowheads[Small], Brown], Arrowheads[Small]}, EdgeLabels -> {12 -> "edge"}];AnnotationDelete[{[image], 12}, EdgeStyle]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]]];AnnotationDelete[{[image], 12}, EdgeLabels]顶点注释 (1)
g = CompleteGraph[4, VertexSize -> Small]AnnotationValue[{g, 4}, VertexStyle] = Red;
AnnotationValue[{g, 1}, VertexLabels] = "hello";
AnnotationValue[{g, 1}, VertexShape] = [image];
AnnotationValue[{g, 1}, VertexSize] = Large;
AnnotationValue[{g, 2}, VertexShapeFunction] = "Square";AnnotationValue[{g, 1}, VertexWeight] = 100;AnnotationValue[{g, 2}, "Material"] = "Wood";g删除包括 VertexStyle 的顶点注释:
AnnotationDelete[{g, 4}, VertexStyle]AnnotationDelete[{g, 1}, VertexLabels]AnnotationDelete[{g, 1}, VertexSize]AnnotationDelete[{g, 1}, VertexShape]AnnotationDelete[{g, 2}, VertexShapeFunction]AnnotationDelete[{g, 1}, VertexCoordinates]MemberQ[PropertyList[{g, 2}], "Material"]AnnotationDelete[{g, 2}, "Material"];MemberQ[PropertyList[{%, 2}], "Material"]边注释 (1)
g = CompleteGraph[4]AnnotationValue[{g, 12}, EdgeStyle] = Brown;
AnnotationValue[{g, 12}, EdgeLabels] = "hello";
AnnotationValue[{g, 34}, EdgeShapeFunction] = "HalfFilledDoubleArrow";
AnnotationValue[{g, 12}, EdgeWeight] = 42;
AnnotationValue[{g, 24}, "Resistance"] = 50.;g删除包括 EdgeStyle 的边注释:
AnnotationDelete[{g, 12}, EdgeStyle]AnnotationDelete[{g, 12}, EdgeLabels]AnnotationDelete[{g, 34}, EdgeShapeFunction]MemberQ[AnnotationKeys[{g, 24}], "Resistance"]AnnotationDelete[{g, 24}, "Resistance"];MemberQ[AnnotationKeys[{%, 24}], "Resistance"]区域 (4)
CSGRegion["Union", {Style[Ball[], Red], Style[Cuboid[], Blue]}]AnnotationDelete[{%, {1}}, "CSGRegionStyle"]CSGRegion["Union", {Style[Annotation[Ball[], "Material" -> "Metal"], Red], Cuboid[]}]AnnotationDelete[{%, {1}}]CSGRegion["Union", {Style[Annotation[Ball[], "Material" -> "Wood"], Red], Style[Cuboid[], Blue]}]AnnotationDelete[%, "CSGRegionStyle"]AnnotationKeys[{%, {1}}]删除 CSGRegion 对象中的所有注释:
CSGRegion["Union", {Style[Annotation[Ball[], "Material" -> "Wood"], Red], Style[Cuboid[], Blue]}]AnnotationDelete[%]AnnotationKeys[{%, {1}}]应用 (2)
Linda 希望在家庭聚会的介绍中保持匿名. 隐藏她的顶点标签:
ExampleData[{"NetworkGraph", "FamilyGathering"}]AnnotationDelete[{%, "Linda"}, VertexLabels]使用 Fold 重复应用 AnnotationDelete:
g = CycleGraph[8, VertexStyle -> Table[i -> RandomChoice[{Red, Green, Blue}], {i, 8}], VertexSize -> Large]Fold[AnnotationDelete[{#1, #2}, VertexStyle]&, g, Range[1, 7]]FoldList[AnnotationDelete[{#1, #2}, VertexStyle]&, g, Range[1, 7]]属性和关系 (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使用 AnnotationKeys 来测试注释的存在:
g = CompleteGraph[4, VertexLabels -> {1 -> one, 4 -> four}]MemberQ[AnnotationKeys[{g, 1}], VertexLabels]Cases[VertexList[g], v_ /; MemberQ[AnnotationKeys[{g, v}], VertexLabels] :> v -> AnnotationValue[{g, v}, VertexLabels]]使用 Annotate 设置注释而不更改原图:
g = CompleteGraph[4]Annotate[{g, 1}, VertexSize -> Medium]g可能存在的问题 (1)
AnnotationValue 通常比 AnnotationDelete 更快:
g = Graph[Annotation[#, VertexWeight -> 10.]& /@ Range[1000], {}];Timing@Do[AnnotationValue[{g, v}, VertexWeight]=., {v, VertexList[g]}]g = Graph[Annotation[#, VertexWeight -> 10.]& /@ Range[1000], {}];Timing@Do[g = AnnotationDelete[{g, v}, VertexWeight], {v, VertexList[g]}]文本
Wolfram Research (2019),AnnotationDelete,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AnnotationDelete.html (更新于 2025 年).
CMS
Wolfram 语言. 2019. "AnnotationDelete." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/AnnotationDelete.html.
APA
Wolfram 语言. (2019). AnnotationDelete. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AnnotationDelete.html 年
BibTeX
@misc{reference.wolfram_2026_annotationdelete, author="Wolfram Research", title="{AnnotationDelete}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/AnnotationDelete.html}", note=[Accessed: 16-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_annotationdelete, organization={Wolfram Research}, title={AnnotationDelete}, year={2025}, url={https://reference.wolfram.com/language/ref/AnnotationDelete.html}, note=[Accessed: 16-August-2026]}