2

I am struggling to find out how to change the angle between nodes in tikz trees. I have already tried the attribute sibling angle=... specifically for child nodes or as level 1/.style=... attribute at the beginning of the \tikzpicture environment. Sibling distance works for me, but Sibling angle does not change anything. Look at the following example:

What I want is that the angle between B and C gets wider or narrower. I need that for a bigger tree where there is a lot of overlapping.

Code:

\documentclass{article}    
\usepackage[latin1]{inputenc}
\usepackage{tikz}
\usetikzlibrary{trees}

%------------------ Tikz Settings----------------------------    
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=3.5cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]

%Define tree diagram styles   
\tikzstyle{Decision} = [shape=rectangle,
                        draw,
                        double=black,
                        double distance=1pt,
                        text=black]
\tikzstyle{Lottery} = [shape=circle,
                        draw,
                        double=black,
                        double distance=1pt,
                        text=black]
\tikzstyle{Outcome}     = [circle,
                       minimum width=3pt,
                       fill, 
                       inner sep=0pt]

\begin{document}   
        \begin{figure}
                \centering                  
                \begin{tikzpicture}[grow=right, sloped, scale=0.7,level 1/.style={sibling angle=60, sibling distance=60mm}]         
                \node [Decision,label=left:{}] {A}
                [node distance = 100mm]
                child[sibling angle=10]{ 
                    node[Decision,label=right:{}] {B}
                        edge from parent
                        node[above] {}
                    }
                child{ 
                    node[Decision,label=right:{}] {C}
                    edge from parent
                    node[above] {}
                };      
                \end{tikzpicture}                       
        \end{figure}
\end{document}
  • 1
    From TikZ manual follows: /tikz/sibling angle=<angle> Sets the angle between siblings in the grow cyclic style. Since you not declare grow cyclic, this option has no influence on tree. – Zarko Jan 25 '16 at 19:45
  • forest has something like this. But with forest you probably wouldn't need to set it manually anyway. \tikzstyle is deprecated by the way. – cfr Jan 26 '16 at 2:08
2

If you are prepared to use forest, you can specify the angles between the siblings and their parent nodes etc. in various ways. Note, however, that forest is pretty good at auto-adjusting these kinds of things, so you may not really need to set them manually.

\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\tikzset{
  Decision/.style = {%
    draw,
    line width=1.4pt
  },
  Lottery/.style = {%
    draw,
    line width=1.4pt
  },
  Outcome/.style = {%
    circle,
    minimum width=3pt,
    fill,
    inner sep=0pt
  }
}

\begin{document}
\begin{forest}
  for tree={
    grow=0,
    Decision,
    calign angle=60,
    calign=fixed edge angles,
  }
  [A
    [B, calign secondary angle=80, calign primary angle=-60
      [D]
      [E]
    ]
    [C, calign secondary angle=70, calign primary angle=-60
      [F]
      [G]
    ]
  ]
\end{forest}

\end{document}

angles in trees

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.