2

I'm following the solution from this post to construct a tree using tikz-qtree. It's working very well as you can see on the image below.

enter image description here

The tree is to show the matches of a championship.

But I'd like to reflect (duplicating) the tree to show the other matches, that is, to go up from champion to the Finalist 2 and so on.

Here is my code:

\documentclass[landscape]{article}
\usepackage[margin=1in,a3paper]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees}

\begin{document}
\begin{tikzpicture}
\Tree [.Champion 
        [.{Finalist 1}
            [.{Semi Finalist 1} 
               [.{kk}
                 [. kk ]
                 [. kk ]  ]
               [.{kk} 
                 [. kk ]
                 [. kk ] ] ]
            [.{Semi finalist 2} 
                           [.{kk}
                             [. kk ]
                             [. kk ]  ]
                           [.{kk} 
                             [. kk ]
                             [. kk ] ] ]
                              ] 
]
\end{tikzpicture}  
\end{document}
7
  • Does \tikzset{grow=up} do anything (and/or grow')? May 10, 2013 at 0:12
  • I'm using \tikzset{edge from parent fork down}.
    – Sigur
    May 10, 2013 at 0:15
  • Well, then edge from parent fork up? May 10, 2013 at 0:16
  • @Qrrbrbirlbel, no. This changes the connectors. I want them like the figure and also going up, a kind of mixture of down and up.
    – Sigur
    May 10, 2013 at 0:21
  • 1
    Down and up? Huh. So, the nodes reflect the teams not the matches? You want the same tree mirrored to have a X-like figure? May 10, 2013 at 0:24

2 Answers 2

4

You can do this more or less how Qrrbrbirlbel suggests (unless I've misunderstood what you want.)

\documentclass[landscape]{article}
\usepackage[margin=1in,a3paper]{geometry}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees}
\tikzset{font=\small,
edge from parent fork down,
level distance=1.75cm,
every node/.style=
    {top color=white,
    bottom color=blue!25,
    rectangle,rounded corners,
    minimum height=8mm,
    draw=blue!75,
    very thick,
    drop shadow,
    align=center,
    text depth = 0pt
    },
edge from parent/.style=
    {draw=blue!50,
    thick
    }}
\begin{document}
\begin{tikzpicture}

\begin{scope}[edge from parent fork up,grow'=up]
\Tree [
        [.{Finalist 1}
            [.{Semi Finalist 1} 
               [.{kk}
                 [. kk ]
                 [. kk ]  ]
               [.{kk} 
                 [. kk ]
                 [. kk ] ] ]
            [.{Semi finalist 2} 
                           [.{kk}
                             [. kk ]
                             [. kk ]  ]
                           [.{kk} 
                             [. kk ]
                             [. kk ] ] ]
                              ] 
]
\end{scope}
\begin{scope}
\Tree [.Champion
        [.{Finalist 1}
            [.{Semi Finalist 1} 
               [.{kk}
                 [. kk ]
                 [. kk ]  ]
               [.{kk} 
                 [. kk ]
                 [. kk ] ] ]
            [.{Semi finalist 2} 
                           [.{kk}
                             [. kk ]
                             [. kk ]  ]
                           [.{kk} 
                             [. kk ]
                             [. kk ] ] ]
                              ] 
]
\end{scope}
\end{tikzpicture}  
\end{document}

output of code

4
  • More or less. I would like to identify both champion nodes. It's strange to show that node two times.
    – Sigur
    May 10, 2013 at 0:28
  • So you mean you want to have a single champion node shared by both? Then just remove the yshift parameter from the second scope.
    – Alan Munn
    May 10, 2013 at 0:30
  • OK, it works. But in fact, it prints the node two times but overlapping so that the visual is what I want. Try to change the text of those two nodes, with different sizes. Then we can see both nodes. Every time when I change the champion team I'll need to change in two places. Maybe a command to its name is a good option.
    – Sigur
    May 10, 2013 at 0:41
  • 1
    I removed the duplicate node. The top tree now has no label.
    – Alan Munn
    May 10, 2013 at 1:01
5

Code

\documentclass[tikz,convert=false]{standalone}
\usepackage{tikz-qtree}
\usetikzlibrary{shadows,trees,positioning}

\tikzset{
    font=\small,
    level distance=1.75cm,
    every node/.style={
        top color=white,
        bottom color=blue!25,
        rectangle,rounded corners,
        minimum height=8mm,
        draw=blue!75,
        very thick,
        drop shadow,
        align=center,
        text depth = 0pt
    },
    edge from parent/.style={
        draw=blue!50,
        thick
    }
}
\makeatletter
\tikzset{
    link tree/.style args={#1of#2}{% not so sure about this ...
        every tree node/.append style={#1=\the\tikzleveldistance of #2\if\relax\detokenize{\tikz@growth@anchor}\relax\else.\tikz@growth@anchor\fi,anchor=center}
    }
}
\makeatother
\begin{document}
\begin{tikzpicture}
\node[every tree node/.try] (champ) {Champion};
\begin{scope}[link tree=above of champ, grow=up,edge from parent fork up]
\Tree [.\node (fin2) {Finalist 2};
        [.{Semi Finalist 3} 
           [.{kk}
             [. kk ]
             [. kk ]  ]
           [.{kk} 
             [. kk ]
             [. kk ] ] ]
        [.{Semi finalist 4} 
                       [.{kk}
                         [. kk ]
                         [. kk ]  ]
                       [.{kk} 
                         [. kk ]
                         [. kk ] ] ]
        ]
\end{scope}
\begin{scope}[link tree=below of champ, grow=down, edge from parent fork down]
\Tree
        [.\node (fin1) {Finalist 1};
            [.{Semi Finalist 1} 
               [.{kk}
                 [. kk ]
                 [. kk ]  ]
               [.{kk} 
                 [. kk ]
                 [. kk ] ] ]
            [.{Semi finalist 2} 
                           [.{kk}
                             [. kk ]
                             [. kk ]  ]
                           [.{kk} 
                             [. kk ]
                             [. kk ] ] ]
                              ] 
\end{scope}
\path[edge from parent] (champ) edge (fin2) edge (fin1);
\end{tikzpicture}  
\end{document}

Output

enter image description here

You must log in to answer this question.

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