我正在绞尽脑汁在 LaTex/TikZ 中创建一个思维导图,其中节点不是以方框、圆形或椭圆形显示。有没有办法使用六边形作为子节点来创建思维导图?子节点应该与角落相连。父节点和子节点应该包含一段简短的文本
我已尝试使用形状包。
提前谢谢你,Pjotr
答案1
第一步是按照 leandris 的建议,将节点改为六边形。但这样还不算完。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{mindmap,shapes.geometric}
\begin{document}
\tikzset{hexagon/.style={regular polygon,regular polygon sides=6},
}
\begin{tikzpicture}[concept/.append style={hexagon},
root concept/.append style={concept color=blue,minimum size=1.2cm,
%outer sep=-1em,
font=\sffamily\huge},
level 1 concept/.append style={sibling angle=60,font=\sffamily\large,
%outer sep=-0.5em,
level distance=17em},mindmap]
\node [concept] (n1) {Hello}
[clockwise from=0]
child[concept color=red] {node[concept] (c1) {A}}
child[concept color=orange] {node[concept] (c2) {B}}
child[concept color=green!60!black] {node[concept] (c3) {C}}
child[concept color=brown] {node[concept] (c4) {D}}
child[concept color=yellow] {node[concept] (c5) {E}}
child[concept color=purple] {node[concept] (c6) {F}};
\end{tikzpicture}
\end{document}
如您所见,连接被搞乱了。纠正此问题的一个简单方法是为节点提供一些适当的外部分离。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{mindmap,shapes.geometric}
\begin{document}
\tikzset{hexagon/.style={regular polygon,regular polygon sides=6},
}
\begin{tikzpicture}[concept/.append style={hexagon},
root concept/.append style={concept color=blue,minimum size=1.2cm,
outer sep=-1em,
font=\sffamily\huge},
level 1 concept/.append style={sibling angle=60,font=\sffamily\large,
outer sep=-0.5em,
level distance=17em},mindmap]
\node [concept] (n1) {Hello}
[clockwise from=0]
child[concept color=red] {node[concept] (c1) {A}}
child[concept color=orange] {node[concept] (c2) {B}}
child[concept color=green!60!black] {node[concept] (c3) {C}}
child[concept color=brown] {node[concept] (c4) {D}}
child[concept color=yellow] {node[concept] (c5) {E}}
child[concept color=purple] {node[concept] (c6) {F}};
\end{tikzpicture}
\end{document}
思维导图通常情况下,结果在某种程度上取决于查看器。图示的输出是您使用 Acrobat Reader 获得的输出。
附录: 看到之后这个很酷的答案我重读了一遍问题。你只希望外部节点为六边形。很好。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{mindmap,shapes.geometric}
\begin{document}
\tikzset{hexagon/.style={regular polygon,regular polygon sides=6},
}
\begin{tikzpicture}[root concept/.append style={concept color=blue,minimum size=1.2cm,
font=\sffamily\huge},
level 1 concept/.append style={sibling angle=60,font=\sffamily\large,
outer sep=-0.5em,concept/.append style={hexagon},
level distance=14em},mindmap]
\node [concept] (n1) {Hello}
[clockwise from=0,]
child[concept color=red] {node[concept] (c1) {A}}
child[concept color=orange] {node[concept] (c2) {B}}
child[concept color=green!60!black] {node[concept] (c3) {C}}
child[concept color=brown] {node[concept] (c4) {D}}
child[concept color=yellow] {node[concept] (c5) {E}}
child[concept color=purple] {node[concept] (c6) {F}};
\end{tikzpicture}
\end{document}