11

I am using the following tikz example (original source)

MWE:

% Author: Till Tantau
% Source: The PGF/TikZ manual
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{mindmap,trees}
\begin{document}
\pagestyle{empty}
\begin{tikzpicture}
  \path[mindmap,concept color=black,text=white]
    node[concept] {Computer Science}
    [clockwise from=0]
    child[concept color=green!50!black] {%
      node[concept] {practical}
      [clockwise from=90]
      child {node[concept] {algorithms} }
      child {node[concept] {data structures} }
      child {node[concept] {pro\-gramming languages} }
      child {node[concept] {software engineer\-ing} }
    }  
    child[concept color=blue] {%
      node[concept] {applied}
      [clockwise from=-30]
      child {node[concept] {databases} }
      child {node[concept] {WWW} }
    }
    child[concept color=red] {node[concept] {technical} }
    child[concept color=orange] {node[concept] {theoretical} };
\end{tikzpicture}\end{document}

Output:

enter image description here

Where each child is spread 60 degrees apart. I presume you control this spacing with sibling angle=60 (got the idea from here), but I can't use it to change the spacing. Could someone modify the MWE to illustrate how to use it. I would very much appreciate it if you could use a different angle for each branch (including the main branch). Thank you.

EDIT: There seems to be some confusion as people think I want to space things out randomly. What I want is this instead, if a node has two children, I want to define the spacing to be 180 degrees, if it has 3 children, I want the spacing to be 120 degrees, 4 children, 90 degrees, 5 children 72 degrees and so on. As is, I must have 6 children for it to not look weird.

7
  • 1
    Within the example that you suggested: Scientific interactions, syntax child [grow=-10, level distance=160] is used to place child at certain angle and distance from its parent concept. Is this what you want?
    – Ignasi
    Commented Jun 11, 2013 at 7:43
  • You can also give node position: child[concept color=orange ] {node[concept] at (-3,-2) {theoretical} };
    – Penbeuz
    Commented Jun 11, 2013 at 7:47
  • The original source for your example is pgfmanual. There you find a comment which says note that 'sibling angle' can only be defined in 'level 1 concept/.append style={}'.
    – Ignasi
    Commented Jun 11, 2013 at 7:50
  • @Ignasi sadly I am not sure what that means
    – puk
    Commented Jun 11, 2013 at 8:49
  • Means that sibling angle has to be defined for every level, it's not possible to apply it to a particular concept. If you want to apply diferent angles to every concept whithin a certain level, you must use grow or at syntax.
    – Ignasi
    Commented Jun 11, 2013 at 9:00

1 Answer 1

13

The style set angles for level is used to append the correct sibling distance for level #1.

It can either used inside the level style or possibly in a .listed option.

Usage should vary depending on the use-case in a real document. It may preferable to append set angles for level to grow cyclic or create a custom special grow cyclic that used this solution.

Code

\documentclass[tikz,convert=false]{standalone}
\usetikzlibrary{mindmap,trees,graphs}
\tikzset{
  set angles for level/.style={level #1/.append style={sibling angle=360/\the\tikznumberofchildren}},
  level/.append style={set angles for level=#1}% solution 1
}
\begin{document}
\begin{tikzpicture}
  \path[
    mindmap,
    concept color=black,
    text=white,
    grow cyclic,
    nodes=concept,
%    set angles for level/.list={1,...,4}% solution 2
  ]
  node {Computer Science} 
    child[concept color=green!50!black] {%
      node {practical}
      child {node {algorithms} }
      child {node {data structures} }
      child {node {pro\-gramming languages} }
      child {node {software engineer\-ing} }
      child {node {and a fifth}}
    }  
    child[concept color=blue] { node[concept] {applied}
      child {node {databases} }
      child {node {WWW} }
    }
    child[concept color=red] {node {technical} }
    child[concept color=orange] {node {theoretical} };
\end{tikzpicture}
\end{document}

Output

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .