TreeElementShape
Treeおよび関連関数のオプションで,部分木要素に使用するグラフィックスを指定する.
詳細
- TreeElementShapeを使うと,木の根のノードの形状およびパターンにマッチする位置にある任意の部分木の形状が指定できる.
- TreeElementShapeは,Graphicsオブジェクト,Graphics3Dオブジェクト,Imageオブジェクトのいずれでもよい.
- オブジェクトの中心はTreeElementCoordinatesで指定されたグラフィックスの位置になる. »
- 各部分木の描画された形はTreeElementSizeで指定されるように与えられたオブジェクトをスケールし直すことで得られる. »
- 次は,使用可能なオプション設定である.
-
Automatic 自動形状を使う g ノードにグラフィックス g を使う » Allg 全ノードに g を使う » TreeCases[pattern]g データが pattern にマッチするノードに g を使う » "Leaves"g 葉に g を使う » "NonLeaves"g 葉以外に g を使う » {pos1g1,pos2g2,…} 相対位置 posiにあるノードに giを使う » {patt1g1,patt2g2,…} パターン pattiにマッチする位置にあるノードに giを使う » - TreeElementShapeFunctionの指定はTreeElementShapeの指定をオーバーライドする. »
例題
すべて開く すべて閉じる例 (4)
Tree[1, {2, 3}, TreeElementShape -> [image], TreeElementSize -> All -> Large]Tree[1, {2, 3}, TreeElementShape -> {{} -> [image], {1} -> [image], {2} -> [image]}, TreeElementSize -> All -> Large]Tree[1, {2, 3}, TreeElementShape -> All -> [image], TreeElementSize -> All -> Large]Tree[1, {2, 3}, TreeElementShape -> {"Leaves" -> [image], "NonLeaves" -> [image]}, TreeElementSize -> All -> Large]スコープ (2)
Tree[1, {[image], [image], [image]}, TreeElementShape -> {{} -> [image], {___, 1} -> [image], {2} -> [image]}, TreeElementSize -> All -> Large]Tree[1, {[image], [image], [image]}, TreeElementShape -> {TreeCases[1] -> [image], TreeCases[_ ? EvenQ] -> [image], TreeCases[_ ? OddQ] -> [image]}, TreeElementSize -> All -> Large]特性と関係 (7)
オブジェクトの中心はTreeElementCoordinatesで指定されたグラフィックスの位置になる:
Table[Tree[1, {2, 3}, TreeElementShape -> [image], TreeElementCoordinates -> {{} -> {0, n}, {1} -> {-1, 0}, {2} -> {1, 0}}, PlotLabel -> {0, n}, BaselinePosition -> Bottom, AspectRatio -> 1, TreeElementSize -> All -> Large], {n, 3}]TreeElementShapeはTreeElementSizeと組み合せることができる:
Table[Tree[1, {2, 3}, TreeElementShape -> [image], TreeElementSize -> s, PlotLabel -> s], {s, {Small, Large}}]TreeElementShapeFunctionの指定はTreeElementShapeの指定をオーバーライドする:
Tree[1, {2, 3}, TreeElementShape -> [image], TreeElementSize -> All -> Large]Tree[%, TreeElementShapeFunction -> None]Tree[1, {[image], [image]}, TreeElementShape -> {{} -> [image], {___, 1} -> [image], {2} -> [image]}, TreeElementSize -> All -> Large]部分木によって指定されたスタイルはその祖先によって指定されたスタイルよりも優先順位が高い:
Tree[2, {3}, TreeElementShape -> Automatic]Tree[1, {%}, TreeElementShape -> All -> [image], TreeElementSize -> All -> Large]部分木内の位置{i,j,…}は相対的な位置{i,j,…}にあるその部分木を参照する:
Tree[1, {Tree[2, {3, 4}, TreeElementShape -> {{2} -> [image]}]}, TreeElementSize -> All -> Large]位置{1}における相対位置{2}は大域的位置{1,2}を参照する:
Tree[1, {[image]}, TreeElementShape -> {{1, 2} -> [image]}, TreeElementSize -> All -> Large]一般に,パターン patt は patt にマッチする大域的位置{i,j,…}にある部分木に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementShape -> {pos_ /; Total[pos] === 2 -> [image]}]}, TreeElementSize -> All -> Large]パターンのリスト{patt1,patt2,…}は pattiにマッチする相対位置{i,j,…}に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementShape -> {{1} -> [image]}]}, TreeElementSize -> All -> Large]考えられる問題 (1)
TreeElementShapeは,ノードに使われるグラフィックスあるいは画像を取る:
Tree[1, {2, 3}, TreeElementShape -> All -> [image], TreeElementSize -> All -> Large]TreeElementShapeFunctionは,グラフィックスあるいは画像を描画するためにInsetを必要とする:
Tree[1, {2, 3}, TreeElementShapeFunction -> All -> (Inset[[image], #, Center, 2 * #3]&), TreeElementSize -> All -> Large]関連するガイド
-
▪
- 木構造の可視化
テキスト
Wolfram Research (2022), TreeElementShape, Wolfram言語関数, https://reference.wolfram.com/language/ref/TreeElementShape.html.
CMS
Wolfram Language. 2022. "TreeElementShape." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TreeElementShape.html.
APA
Wolfram Language. (2022). TreeElementShape. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeElementShape.html
BibTeX
@misc{reference.wolfram_2026_treeelementshape, author="Wolfram Research", title="{TreeElementShape}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TreeElementShape.html}", note=[Accessed: 03-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_treeelementshape, organization={Wolfram Research}, title={TreeElementShape}, year={2022}, url={https://reference.wolfram.com/language/ref/TreeElementShape.html}, note=[Accessed: 03-November-2026]}