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.

puk
  • 3,061
  • 5
  • 30
  • 41
  • 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 Jun 11 '13 at 07:43
  • You can also give node position: child[concept color=orange ] {node[concept] at (-3,-2) {theoretical} }; – Penbeuz Jun 11 '13 at 07: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 Jun 11 '13 at 07:50
  • @Ignasi sadly I am not sure what that means – puk Jun 11 '13 at 08: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 Jun 11 '13 at 09:00
  • @Ignasi I clarified the question – puk Jun 11 '13 at 19:44
  • Are you sure about the angles? From where do you measure? A child can possibly overlap its grandparent. Without taking a look into the manual if something like this exist, I believe this needs an own growth function (for automatic calculation of the angles). – Qrrbrbirlbel Jun 11 '13 at 22:32

1 Answers1

12

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

Qrrbrbirlbel
  • 119,821