Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to build this decision tree I was take out fill option at

\tikzstyle{choice} = [circle, minimum width=8pt, fill, inner sep=0pt]

and also make the tree grow down

\tikzstyle{level 1}=[level distance=1.5cm, sibling distance=2.5cm]
\tikzstyle{level 2}=[level distance=1cm, sibling distance=2cm]
\tikzstyle{level 3}=[level distance=1cm, sibling distance=1.5cm]
\tikzstyle{bag} = [circle, text width=4em, text centered, draw]
\tikzstyle{decision} = [rectangle, minimum height=8pt, minimum width=8pt, fill, inner sep=0pt]
\tikzstyle{choice} = [circle, minimum width=8pt, fill, inner sep=0pt]
\tikzstyle{end} = [circle, text width=1em, text centered, draw, inner sep=0pt]

\begin{tikzpicture}[grow=right, child anchor=west]
\tiny
\node[bag]{XOR}
child {
    node[decision]{TEST}
    child {
        node[bag]{A= 0}
            child{
                node[choice]{}
                child {
                    node[bag]{B=0}
                    child {
                        node[end]{0}
                    }
                }
                child {
                    node[bag]{B=1}
                    child {
                        node[end]{1}
                    }
                }
            }
    }
    child {
        node[bag]{A=1}
            child{
                node[choice]{}
                child {
                    node[bag]{B=0}
                    child {
                        node[end]{1}
                    }
                }
                child {
                    node[bag]{B=1}
                    child {
                        node[end]{0}
                    }
                }
            }
        }
    };

\end{tikzpicture}
share|improve this question
2  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. With a few more lines you can make this example fully compilable by copy/pasting :) –  percusse Oct 3 '12 at 12:52
    
I don't quite understand what you are asking. The default behaviour is for the tree to grow down. You can make it grow "west" instead with the grow=left option. –  Seamus Oct 3 '12 at 13:05
    
My tree grows side ways i want to grow it downwards natural progression, i am very new to latex –  find-missing-semicolon Oct 3 '12 at 13:13
add comment

1 Answer 1

up vote 5 down vote accepted

If you don't give any options, the tree grows downwards, naturally. I have changed

\tikzstyle{decision} = [rectangle, minimum height=8pt, minimum width=8pt, fill, inner sep=0pt]

to

\tikzstyle{choice} = [circle, minimum width=8pt, draw, inner sep=0pt]

to remove the fill. Also you have to use appropriate distances in

\tikzstyle{level 2}=[level distance=1cm, sibling distance=5cm]

so that things don't overlap.

Your code becomes

\documentclass{article}
\usepackage{tikz}
\begin{document}
\tikzstyle{level 1}=[level distance=1.5cm, sibling distance=2.5cm]
\tikzstyle{level 2}=[level distance=1cm, sibling distance=5cm]
\tikzstyle{level 3}=[level distance=1cm, sibling distance=2cm]
\tikzstyle{bag} = [circle, text width=4em, text centered, draw]
\tikzstyle{decision} = [rectangle, minimum height=8pt, minimum width=8pt, fill, inner sep=0pt]
\tikzstyle{choice} = [circle, minimum width=8pt, draw, inner sep=0pt]
\tikzstyle{end} = [circle, text width=1em, text centered, draw, inner sep=0pt]

\begin{tikzpicture}%%[grow=left, child anchor=east]
\tiny
\node[bag]{XOR}
child {
    node[decision]{TEST}
    child {
        node[bag]{A= 0}
            child{
                node[choice]{}
                child {
                    node[bag]{B=0}
                    child {
                        node[end]{0}
                    }
                }
                child {
                    node[bag]{B=1}
                    child {
                        node[end]{1}
                    }
                }
            }
    }
    child {
        node[bag]{A=1}
            child{
                node[choice]{}
                child {
                    node[bag]{B=0}
                    child {
                        node[end]{1}
                    }
                }
                child {
                    node[bag]{B=1}
                    child {
                        node[end]{0}
                    }
                }
            }
        }
    };

\end{tikzpicture}
\end{document}

enter image description here

Hope that helps!

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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