AnnotationRules
是一个选项,允许指定对象和对象中的项的注释.
更多信息
- 通常用于指定对象和对象中项的注释.
- 带有可注释项的可能对象:
-
Audio 时间点和时间区间 BoundaryMeshRegion 网格单元 CSGRegion 几何区域 Graph 顶点和边 MeshRegion 网格单元 - AnnotationRules 始终转换为具有结构的优化标准格式.
- AnnotationRules 选项可用于在诸如 Subgraph、EdgeAdd 和 GraphUnion 之类的结构中指定注释的继承.
- 注释继承的典型设置包括:
-
Inherited 继承所有注释 Automatic 使用自动注释继承 None 设置无继承
范例
打开所有单元 关闭所有单元基本范例 (2)
mr = MengerMesh[1, AnnotationRules -> {{2, 1} -> {"marker" -> 1}}];AnnotationValue[{mr, {2, 1}}, "marker"]graph = [image];Subgraph[graph, {28, 38, 48, 27, 37, 47, 26, 36, 46}, AnnotationRules -> Inherited]Subgraph[graph, {28, 38, 48, 27, 37, 47, 26, 36, 46}, AnnotationRules -> Automatic]Subgraph[graph, {28, 38, 48, 27, 37, 47, 26, 36, 46}, AnnotationRules -> None]范围 (12)
图与网络 (12)
图注释 (8)
Graph[{12, 23, 31}, AnnotationRules -> {1 -> {VertexLabels -> "hello"}}]Graph[{12, 23, 31}, AnnotationRules -> {12 -> {EdgeLabels -> "hello"}}]Graph[{12, 23, 31}, AnnotationRules -> {"GraphProperties" -> {"Message" -> "hello"}}]AnnotationValue[%, "Message"]Graph[{12, 23, 31}, AnnotationRules -> {"DefaultVertexProperties" -> {VertexStyle -> Red}}, VertexSize -> Small]Graph[{12, 23, 31}, AnnotationRules -> {"DefaultEdgeProperties" -> {EdgeStyle -> Dashed}}]AnnotationRules 适用于无向图:
Graph[{1, 2, 3}, {12, 23, 31}, AnnotationRules -> {12 -> {EdgeStyle -> Brown}}]Graph[{1, 2, 3}, {12, 23, 31}, AnnotationRules -> {12 -> {EdgeStyle -> Dashed}}, EdgeStyle -> Arrowheads[Small]]Graph[{1, 2, 3}, {12, 23, 23, 23, 31}, AnnotationRules -> {12 -> {EdgeStyle -> Brown}}]Graph[{1, 2, 3}, {12, 23, 31}, AnnotationRules -> {12 -> {EdgeStyle -> Dashed}}, EdgeStyle -> Arrowheads[0.08]]Graph[{1, 2, 3}, {12, 23, 31}, EdgeWeight -> {0.5, 1, 1}, AnnotationRules -> {12 -> {EdgeStyle -> Dashed}}]顶点注释 (2)
标准顶点注释包括 VertexStyle:
Graph[{12, 23, 31}, AnnotationRules -> {1 -> {VertexStyle -> Red}}]Graph[{12, 23, 31}, AnnotationRules -> {1 -> {VertexLabels -> "hello"}}]Graph[{12, 23, 31}, AnnotationRules -> {1 -> {VertexSize -> Small}}]Graph[{12, 23, 31}, VertexSize -> Medium, AnnotationRules -> {1 -> {VertexShape -> [image]}}]Graph[{12, 23, 31}, AnnotationRules -> {1 -> {"Material" -> "Wood"}}]AnnotationValue[{%, 1}, "Material"]边注释 (2)
包括 EdgeStyle 的标准边注释:
Graph[{12, 23, 31}, AnnotationRules -> {12 -> {EdgeStyle -> Brown}}]Graph[{12, 23, 31}, AnnotationRules -> {12 -> {EdgeLabels -> "hello"}}]Graph[{12, 23, 31}, AnnotationRules -> {12 -> {EdgeShapeFunction -> "DashedLine"}}]Graph[{12, 23, 31}, AnnotationRules -> {12 -> {"Resistance" -> 50.}}]AnnotationValue[{%, 12}, "Resistance"]应用 (4)
Graph[{1, 2, 3, 4, 5, 6}, {41, 12, 23, 25, 36, 45, 56}, AnnotationRules -> {41 -> {EdgeLabels -> "Voltage source"}, 12 -> {EdgeLabels -> "Resistance"},
23 -> {EdgeLabels -> "Inductance"},
25 -> {EdgeLabels -> "Capactitance"},
36 -> {EdgeLabels -> "Bulb"},
45 -> {EdgeLabels -> "Wire"},
56 -> {EdgeLabels -> "Wire"}}, GraphLayout -> "SpringEmbedding", VertexSize -> 0, ImagePadding -> {{30, 10}, {5, 5}}]g = Graph[{Annotation[1, {VertexWeight -> 42, VertexLabels -> "hello"}], Annotation[2, {"Material" -> "Wood", VertexStyle -> Green}], Annotation[3, VertexSize -> Medium]}, {12, 23, Annotation[31, EdgeStyle -> Dashed]}]Options 使用 AnnotationRules 处理一些注释:
Options[g]Graph@@@HoldForm[Evaluate[{VertexList[g], EdgeList[g], Options[g]}]]ReleaseHold[%]% == g使用 Table 为许多项设置类似的注释:
CycleGraph[15, AnnotationRules -> Table[v -> {VertexSize -> 0.2 + 0.2Mod[v, 5], VertexStyle -> Hue[(v/15), 1, 1]}, {v, 15}]]当注释值在列表中可用时,请使用 Thread:
values = {{Small, Green}, {Small, White}, {Small, Green}, {Medium, Red}, {Medium, Green}, {Medium, White}};CycleGraph[6, AnnotationRules -> Table[v -> Thread[{VertexSize, VertexStyle} -> values[[v]]], {v, 6}]]文本
Wolfram Research (2019),AnnotationRules,Wolfram 语言函数,https://reference.wolfram.com/language/ref/AnnotationRules.html (更新于 2025 年).
CMS
Wolfram 语言. 2019. "AnnotationRules." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2025. https://reference.wolfram.com/language/ref/AnnotationRules.html.
APA
Wolfram 语言. (2019). AnnotationRules. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/AnnotationRules.html 年
BibTeX
@misc{reference.wolfram_2026_annotationrules, author="Wolfram Research", title="{AnnotationRules}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/AnnotationRules.html}", note=[Accessed: 07-August-2026]}
BibLaTeX
@online{reference.wolfram_2026_annotationrules, organization={Wolfram Research}, title={AnnotationRules}, year={2025}, url={https://reference.wolfram.com/language/ref/AnnotationRules.html}, note=[Accessed: 07-August-2026]}