TreeElementStyle
Treeおよび関連関数のオプションで,部分木の要素に使うスタイルを指定する.
詳細
- TreeElementStyleを使うと,木の根のノードのスタイルおよびパターンにマッチする位置にある任意の部分木のスタイルが指定できる.
- 次は,使用可能なオプションである.
-
Automatic 自動スタイルを使う style style をノードに使う » Allstyle style を全ノードに使う » TreeCases[pattern]style pattern にマッチするデータのノードに style を使う » "Leaves"style 葉に style を使う » "NonLeaves"style 葉以外に style を使う » {pos1style1,pos2style2,…} styleiを相対位置 posiにあるノードに使う » {patt1style1,patt2style2,…} styleiをパターン pattiにマッチする位置にあるノードに使う » - 明示的な要素スタイル posstyle がない部分木は自動スタイルを使うものと解釈される.
- TreeElementStyleは点,線,面に適用できる.
- 複数のスタイル指示子が指定したければDirective[style1,style2,…]を使うとよい.
- 部分木の要素スタイル指定は,事実上,TreeElementStyle,TreeElementStyleFunction,TreeElementShapeFunctionの順に適用され,後の指定が前の指定をオーバーライドする.
例題
すべて開く すべて閉じる例 (4)
Tree[1, {2, 3}, TreeElementStyle -> LightRed]Tree[1, {2, 3}, TreeElementStyle -> {{} -> LightRed, {1} -> LightYellow, {2} -> LightBlue}]Tree[1, {2, 3}, TreeElementStyle -> All -> LightOrange]Tree[1, {2, 3}, TreeElementStyle -> {"Leaves" -> LightBlue, "NonLeaves" -> LightRed}]スコープ (2)
Tree[1, {[image], [image]}, TreeElementStyle -> {{} -> LightRed, {___, 1} -> LightYellow, {2} -> LightBlue}]Tree[1, {[image], [image]}, TreeElementStyle -> {TreeCases[1] -> LightRed, TreeCases[_ ? EvenQ] -> LightYellow, TreeCases[_ ? OddQ] -> LightBlue}]特性と関係 (4)
Tree[1, {[image], [image]}, TreeElementStyle -> {{} -> LightRed, {___, 1} -> LightYellow, {2} -> LightBlue}]部分木によって指定されたスタイルはその祖先によって指定されたスタイルよりも優先される:
Tree[2, {3}, TreeElementStyle -> Automatic]Tree[1, {%}, TreeElementStyle -> All -> LightRed]部分木の位置{i,j,…}は相対位置{i,j,…}にあるその部分木を参照する:
Tree[1, {Tree[2, {3, 4}, TreeElementStyle -> {{2} -> LightYellow}]}]位置{1}の相対位置{2}は大域的位置{1,2}を参照する:
Tree[1, {[image]}, TreeElementStyle -> {{1, 2} -> LightYellow}]一般に,パターン patt は patt にマッチする大域的位置{i,j,…}にある部分木に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementStyle -> {pos_ /; Total[pos] === 2 -> LightBlue}]}]パターンのリスト{patt1,patt2,…}は pattiにマッチする相対位置{i,j,…} に適用される:
Tree[1, {Tree[2, {3, 4}, TreeElementStyle -> {{1} -> LightBlue}]}]テキスト
Wolfram Research (2021), TreeElementStyle, Wolfram言語関数, https://reference.wolfram.com/language/ref/TreeElementStyle.html (2022年に更新).
CMS
Wolfram Language. 2021. "TreeElementStyle." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2022. https://reference.wolfram.com/language/ref/TreeElementStyle.html.
APA
Wolfram Language. (2021). TreeElementStyle. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TreeElementStyle.html
BibTeX
@misc{reference.wolfram_2026_treeelementstyle, author="Wolfram Research", title="{TreeElementStyle}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TreeElementStyle.html}", note=[Accessed: 02-November-2026]}
BibLaTeX
@online{reference.wolfram_2026_treeelementstyle, organization={Wolfram Research}, title={TreeElementStyle}, year={2022}, url={https://reference.wolfram.com/language/ref/TreeElementStyle.html}, note=[Accessed: 02-November-2026]}