如何在 Tikz 思维导图中排序节点

如何在 Tikz 思维导图中排序节点

我刚刚尝试使用 tikz 思维导图,但出现了问题。我不知道如何设置节点 (1) 的两个子节点的左右两侧。它们之间始终有 60° 的间距,我希望它们相隔 180°。

我尝试了水平距离等,grow=leftright都不起作用。我不想改变整个子节点的顺序,只想改变顶部节点的顺序。

这是我的代码:

\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{mindmap,trees}

\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {\normalsize{Reibungsreduktion am Ventiltrieb}}
    [clockwise from=30]
    child[concept color=blue] {
      node[concept] {5}
      [clockwise from=60]
      child { node[concept] {\scriptsize{a}} }
      child { node[concept] {\scriptsize{b} }}
      child { node[concept] {\scriptsize{c} }}
    }
    child[concept color=blue] {
      node[concept] {4}
      [clockwise from=0]
      child { node[concept] {\scriptsize a} }
      child { node[concept] {\scriptsize{b} } }
      child { node[concept] {\scriptsize{c}} }
    }
    child[concept color=blue] {
      node[concept] {3}
      [clockwise from=-60]
      child { node[concept] {\scriptsize{a} }}
      child { node[concept] {\scriptsize{b} }}
      child { node[concept] {\scriptsize{c} }}
    }  
    child[concept color=blue] {
      node[concept] {2}
      [clockwise from=240]
      child { node[concept] {\scriptsize{a}} }
      child { node[concept] {\scriptsize{b}} }
    }
    child[concept color=blue] {
      node[concept] {6}
      [clockwise from=240]
      child { node[concept] {\scriptsize{a}} }
      child { node[concept] {\scriptsize{b}} }
    }
    child[concept color=blue] {
      node[concept] {1}
      [clockwise from=0]
      child { node[concept] {\scriptsize{a}} }
      child { node[concept] {\scriptsize{b} }}
    };
\end{tikzpicture}
\end{document}

答案1

像这样添加[main/.style={sibling angle=180}]到您的:tikzpicture

\begin{tikzpicture}[main/.style={sibling angle=180}]

然后你可以用节点来编写部分,1如下:

...

child[concept color=blue] {
    node[concept] {1}
        [clockwise from =0]
    child[main] { node[concept] {\scriptsize{a}} }
    child[main] { node[concept] {\scriptsize{b} }}
};

...

结果如下:

在此处输入图片描述

答案2

我谦虚地提出了一个小的替代方案:

child[grow=0] { node {a} }
child[grow=180] { node {b }}

和...一起

\begin{tikzpicture}[
        every node/.append style={concept},
        level 2 concept/.append style={node font=\scriptsize}]

这样,您就不必指定每个节点node,也不必在每次位于节点时concept都进行指定。scriptsizelevel 2

完整代码如下:

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[margin=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{mindmap}

\begin{document}
\begin{tikzpicture}[
  every node/.append style={concept},
 level 2 concept/.append style={node font=\scriptsize}]
 \path[mindmap,concept color=black,text=white]
 node {\normalsize{Reibungsreduktion am Ventiltrieb}}
 [clockwise from=30]
 child[concept color=blue] {
  node {5}
  [clockwise from=60]
  child { node {a} }
  child { node {b}}
  child { node {c}}
 }
 child[concept color=blue] {
  node {4}
  [clockwise from=0]
  child { node {a} }
  child { node {b} }
  child { node {c} }
 }
 child[concept color=blue] {
  node {3}
  [clockwise from=-60]
  child { node {a}}
  child { node {b}}
  child { node {c}}
 }  
 child[concept color=blue] {
  node {2}
  [clockwise from=240]
  child { node {a} }
  child { node {b} }
 }
 child[concept color=blue] {
  node {6}
  [clockwise from=240]
  child { node {a} }
  child { node {b} }
 }
 child[concept color=blue] {
  node {1}
  child[grow=0] { node {a} }
  child[grow=180] { node {b}}
 };
\end{tikzpicture}
\end{document}

相关内容