我尝试了一段时间,想弄清楚如何在思维导图的同一层级上为不同的节点使用不同的兄弟角度。兄弟角度应该自定义。这是我的示例:
\begin{tikzpicture}
\path[mindmap, concept color=black, text=white, level 1 concept/.append style={level distance=52mm, sibling angle=100}, level 2 concept/.append style={sibling angle=40}]
node[concept] {Parent}
[clockwise from=-40]
child[concept color=blue] {
node[concept] {Child 2}
[clockwise from=60]
child {node[concept] {Grandchild 1}}
child {node[concept] {Grandchild 2}}
child {node[concept] {Grandchild 3}}
child {node[concept] {Grandchild 4}}
child {node[concept] {Grandchild 5}}
child {node[concept] {Grandchild 6}}}
child[concept color=green!60!black] {
node[concept] {Child 1}
[clockwise from=0]
child{node[concept] {Grandchild 1}}
child{node[concept] {Grandchild 2}}
child{node[concept] {Grandchild 3}}
child{node[concept] {Grandchild 4}}
child{node[concept] {Grandchild 5}}
child{node[concept] {Grandchild 6}}
child{node[concept] {Grandchild 7}}
child{node[concept] {Grandchild 8}}};
\end{tikzpicture}
孩子 1 的兄弟姐妹角度看起来还不错,但我想改变孩子 2 的兄弟姐妹角度,让孙辈分布得更均匀。有人知道怎么做吗?
答案1
您可以在子项 2 的关键字中更改第 2 级的兄弟角度:
\documentclass[tikz,margin=10pt]{standalone}
\usetikzlibrary{mindmap}
\begin{document}
\begin{tikzpicture}
\path[mindmap, concept color=black, text=white,
level 1 concept/.append style={level distance=52mm, sibling angle=100},
level 2 concept/.append style={sibling angle=40}]
node[concept] {Parent}
[clockwise from=-40]
child[concept color=blue] {
node[concept] {Child 2}
[clockwise from=85, level 2 concept/.append style={sibling angle=50}]
child {node[concept] {Grandchild 1}}
child {node[concept] {Grandchild 2}}
child {node[concept] {Grandchild 3}}
child {node[concept] {Grandchild 4}}
child {node[concept] {Grandchild 5}}
child {node[concept] {Grandchild 6}}}
child[concept color=green!60!black] {
node[concept] {Child 1}
[clockwise from=0]
child{node[concept] {Grandchild 1}}
child{node[concept] {Grandchild 2}}
child{node[concept] {Grandchild 3}}
child{node[concept] {Grandchild 4}}
child{node[concept] {Grandchild 5}}
child{node[concept] {Grandchild 6}}
child{node[concept] {Grandchild 7}}
child{node[concept] {Grandchild 8}}};
\end{tikzpicture}
\end{document}
答案2
另一种选择是定义 2 级圆形均匀分布。
set angles for level/.style={level 2/.append style={sibling angle=360/\the\tikznumberofchildren}},
level/.append style={set angles for level=2}
然后分别调整孙子的起始角度,以防止分支和孙子节点重叠,其中[clockwise from=starting angle]
孙子 1 的起始角度始终为 0。
代码
\documentclass[border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,mindmap}
\begin{tikzpicture}
\path[mindmap, concept color=black, text=white,
level 1 concept/.append style={level distance=60mm, sibling angle=100},
%level 2 concept/.append style={sibling angle=40}
set angles for level/.style={level 2/.append style={sibling angle=360/\the\tikznumberofchildren}},
level/.append style={set angles for level=2}
]
node[concept] {Parent}
[clockwise from=-40]
child[concept color=blue] {
node[concept] {Child 2}
[clockwise from=-8]
child {node[concept] {Grandchild 1}}
child {node[concept] {Grandchild 2}}
child {node[concept] {Grandchild 3}}
child {node[concept] {Grandchild 4}}
child {node[concept] {Grandchild 5}}
child {node[concept] {Grandchild 6}}
}
child[concept color=green!60!black] {
node[concept] {Child 1}
[clockwise from=18]
child{node[concept] {Grandchild 1}}
child{node[concept] {Grandchild 2}}
child{node[concept] {Grandchild 3}}
child{node[concept] {Grandchild 4}}
child{node[concept] {Grandchild 5}}
child{node[concept] {Grandchild 6}}
child{node[concept] {Grandchild 7}}
child{node[concept] {Grandchild 8}}};
\end{tikzpicture}
\end{document}