Example: Hierarchical diagram

Published 2014-07-29 | Authors:

The following diagram uses the forest package to create the diagram as a tree. Shading gives a little depth to the nodes. The shadows library enhances this effect. Two phantom children are used to help aligning the final nodes of the tree and the connecting lines to the first of these are added after the tree is complete, since this node has four parents.

This example was written by cfr answering a question on TeX.SE.

Download as: [PDF] [TEX]  •  [Open in Overleaf]

Hierarchical diagram

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Hierarchical diagram
% Author: cfr
\usetikzlibrary{arrows.meta, shapes.geometric, calc, shadows}


  rect/.append style   = {rectangle, rounded corners = 2pt,
                         inner color = col6in, outer color = col6out},
  ellip/.append style  = {ellipse, inner color = col5in,
                          outer color = col5out},
  orect/.append style  = {rect, font = \sffamily\bfseries\LARGE,
                         text width = 325pt, text centered,
                         minimum height = 10pt, outer color = col7out,
                         inner color=col7in},
  oellip/.append style = {ellip, inner color = col8in, outer color = col8out,
                          font = \sffamily\bfseries\large, text centered}}
  for tree={
      line width=1pt,
      child anchor=north,
      parent anchor=south,
      drop shadow,
      l sep+=12.5pt,
      edge path={
        \noexpand\path[color=linecol, rounded corners=5pt,
          >={Stealth[length=10pt]}, line width=1pt, ->, \forestoption{edge}]
          (!u.parent anchor) -- +(0,-5pt) -|
          (.child anchor)\forestoption{edge label};
      where level={3}{tier=tier3}{},
      where level={0}{l sep-=15pt}{},
      where level={1}{
        if n={1}{
          edge path={
            \noexpand\path[color=linecol, rounded corners=5pt,
              >={Stealth[length=10pt]}, line width=1pt, ->,
              (!u.west) -| (.child anchor)\forestoption{edge label};
          edge path={
            \noexpand\path[color=linecol, rounded corners=5pt,
              >={Stealth[length=10pt]}, line width=1pt, ->,
              (!u.east) -| (.child anchor)\forestoption{edge label};
  [Compressed Sensing\\Theory, inner color=col1in, outer color=col1out
    [Projection Matrix\\Theory, inner color=col2in, outer color=col2out
      [Optimise Projection\\Matrix, inner color=col4in, outer color=col4out]
      [Reduce Number of\\Measurements, inner color=col4in, outer color=col4out]
    [Reconstruction\\Algorithms, inner color=col3in, outer color=col3out
      [Convex Relaxation
        [Sparse Signal\\Estimate, rect, name=sse1
      [Greedy Pursuits
        [Sparse Signal\\Estimate, rect, name=sse2
      [, phantom, calign with current
        [A\\B, phantom
          [Our Work, orect, name=us
            [{Improved Sparse Signal Estimate!}, oellip
      [Non-Convex\\Minimisation Methods
        [Sparse Signal\\Estimate, rect, name=sse3
        [Sparse Signal\\Estimate, rect, name=sse4
  \begin{scope}[color = linecol, rounded corners = 5pt,
    >={Stealth[length=10pt]}, line width=1pt, ->]
    \draw (sse2.south) -- (us.north -| sse2.south);
    \draw (sse3.south) -- (us.north -| sse3.south);
    \coordinate (c1) at ($(sse1.south)!2/5!(sse2.south)$);
    \coordinate (c2) at ($(sse3.south)!2/5!(sse4.south)$);
    \draw (sse1.south) -- +(0,-10pt) -| (us.north -| c1);
    \draw (sse4.south) -- +(0,-10pt) -| (us.north -| c2);


Adding comments is currently not enabled.