# From tree, I cannot make arrows from each node and give the color for each floor and give a layer to that

I want to draw a tree like the below.

\documentclass[article]
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,trees}

\begin{document}
\begin{tikzpicture}[level distance=2cm,
level 1/.style={sibling distance=1.5cm},
level 2/.style={sibling distance=1.7cm},
]
\node {$f$}
child {node {$|f \ast \psi_{\lambda_i}|$  }}
child {node {} }
child {node {}  }
child {node {$|f \ast \psi_{\lambda_1}|$}
child {node {$||f \ast \psi_{\lambda_1}| \ast \psi_{\lambda_j}|$}}
child {node {}}
child {node {}}
child {node {$||f \ast \psi_{\lambda_1}| \ast \psi_{\lambda_2}|$}}
child {node {}}
child {node {}}}
child {node {}}
child {node {}};

\end{tikzpicture}
\end{document}


I tried like this.

First of all, I cannot make arrows from each node. and how can I give the color like the first image. Also, how can I make the block or grouping or make an layer to distinguish each group as I grouped in the first image..

Thanks.

• Please can you make your code into something compilable? – cfr Jul 11 '18 at 22:40
• It isn't really a tree, though part of it is. I guess I might draw it as a tree if it is really an annotated tree, just to keep the structure. (I'm not clear whether that is what it is or not.) – cfr Jul 11 '18 at 22:43
• Oh I edited it into compilable. I have no idea it is tree or not. Actually I'm so dumb to use tex.. – user562093 Jul 12 '18 at 0:59
• Not dumb at all. I meant 'tree' in the graph-theory sense i.e. single route. It is a tree if the labels are not counted. Otherwise, it is hard to make it out to be a tree. – cfr Jul 12 '18 at 15:46
• 'Single route' -> 'single root' .... – cfr Jul 15 '18 at 0:10

I probably wouldn't draw that as a tree. In the code below each box is a single node, with a label defined with the quotes library syntax to add the expressions placed on the left side of the boxes. The syntax of the calc library, which lets you calculate the coordinate that is a fractional distance between two other coordinates, is used to draw the arrows.

Note that I have not written the same expressions as in your image, I'll leave that to you.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{
quotes,
positioning,
calc
}

\newcommand\spaceddots{\hspace{1.5cm}\dots\hspace{1.5cm}}
\begin{document}
\begin{tikzpicture}[
r/.style={red!80!blue},
b/.style={red!20!blue!70},
red box with label/.style={
r,
draw,
"#1"{left,r}
},
blue box with label/.style={
b,
draw,
"#1"{left,b}
},
myarrow/.style={thick,-stealth}
]

\node [red box with label={$S_0\dots$}] (r1) {$f\ast\phi_{1}$};

\node [below=of r1,
xshift=1cm,
red box with label={$S_1\dots$},
"80:$f(x)$"{name=fx}
] (r2) {
$|f\ast\psi_{1}|\ast\phi_1$
\spaceddots
$|f\ast\psi_{1}|\ast\phi_1$};

\node [below=1.5cm of r2.south west,
red box with label={$S_2\dots$}
] (r3) {
$|f\ast\psi_{1}|\ast\phi_1$
\spaceddots
$|f\ast\psi_{1}|\ast\phi_1$};

\node [above=5pt of r3.20,
anchor=south west,
blue box with label={$U_0\dots$}
] (b1) {
$|f\ast\psi_{1}|\ast\phi_1$
\spaceddots
$|f\ast\psi_{1}|\ast\phi_1$};

\node [below=of r3.-20,
blue box with label={$U_1\dots$}
] (b2) {
$|f\ast\psi_{1}|\ast\phi_1$
\spaceddots
$|f\ast\psi_{1}|\ast\phi_1$};

\draw [myarrow,r] (fx.south) -- (r1);

\foreach [count=\i] \x in {0.1,0.3,0.7,0.9}
{
\draw [myarrow,b] (fx.south) -- ($(b1.north west)!\x!(b1.north east)$);
\draw [myarrow,b] ($(b1.south west)!0.1!(b1.south east)$) -- ($(b2.north west)!\x!(b2.north east)$);

\ifnum \i=3
% don't do anything for third one
\else
\draw [myarrow,r] ($(b1.north west)!\x!(b1.north east)$) -- ($(r2.south west)!\x!(r2.south east)$);
\draw [myarrow,r] ($(b2.north west)!\x!(b2.north east)$) -- ($(r3.south west)!\x!(r3.south east)$);
\fi
}

\end{tikzpicture}
\end{document}

• Oh, thanks a lot! Maybe I can try like this. – user562093 Jul 12 '18 at 0:59