-2

What is the best way to draw a taxonomy in the style of the following figure?

Taxonomy

6
\documentclass[tikz,border=10pt]{standalone}
\usepackage{forest}
\usetikzlibrary{shadows}
\tikzset{every shadow/.style={shadow xshift=5pt,shadow yshift=-5pt}}
\begin{document}
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
  for tree={
    font=\sffamily,
    line width=1pt,
    draw,
    child anchor=north,
    parent anchor=south,
    grow=south,
    align=center,
    edge path={
      \noexpand\path[line width=1pt, \forestoption{edge}]
      (!u.parent anchor)  |- ([yshift=4pt].child anchor) -- (.child anchor) \forestoption{edge label};
    },
  },
  s sep+=20pt,
  [1 Clustering Ensemble\\ Approaches,drop shadow,
  fill=white,double=white,
    [2.1 Generative\\ Mechanism,double=white 
     [3.1 Different\\ Algorithms]
     [,phantom]
     [3.2 Single\\ Algorithms
     [4.1 Different built--in\\ initialization]
     [~\\~,opacity=0,name=phantom1
      [4.3 Different subsets\\ of features]
      [~\\~,opacity=0,name=phantom2
       [4.5 Different subsets\\ of objects]
      ]
      [4.4 Projecting data\\ onto different subspaces]
      ]
     [4.2 Different\\ parameters]
     ]
    ]
    [2.2 Consensus\\ Function,double=white
     [3.3 Information Theory\\ Approach]
     [~\\~,opacity=0,name=phantom3
      [3.5 Voting approach]
      [~,opacity=0,name=phantom4
       [3.7 Hypergraph\\ methods]
      ]
      [3.6 Mixture Model (EM)]
      ]
     [3.4 Co--association\\ based approach]
     ]
   ]
  \begin{scope}[line width=1pt]
   \foreach \X in {1,...,4}
   {\draw (phantom\X.north) -- (phantom\X.south);}
  \end{scope}
\end{forest}
\end{document}

enter image description here

| improve this answer | |
  • 1
    Please consider using the edges library for this style of branching. It integrates much better with other options. – cfr Jun 14 '18 at 1:24
4

Here's a version using the Forest edges library, which makes these kinds of trees a lot easier. I've shamelessly stolen marmot's code to avoid typing it all out, but I've altered the structure of the tree a bit to simplify things and relied on Forest options rather than manual spacing, to help ensure consistency and make the code both simpler and more flexible.

I've also tweaked the style as I wasn't keen on the double lines or the squared corners after I'd finished, and found I preferred a subtler shadow for the root, with a very slight shading for all nodes. Obviously, these changes are independent of the Forest code itself, so you can easily get that pushy shadow, hard edges and doubled lines if you prefer them. (In some moods, I might prefer them - but not in this one, apparently.)

\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{shadows.blur}
\begin{document}
% addaswyd o ateb marmot: https://tex.stackexchange.com/a/436172/
% starting point: https://tex.stackexchange.com/a/341454/121799
\begin{forest}
  forked edges,
  for tree={font=\sffamily, rounded corners, top color=gray!5, bottom color=gray!10, edge+={darkgray, line width=1pt}, draw=darkgray, align=center, anchor=children},
  before packing={where n children=3{calign child=2, calign=child edge}{}},
  before typesetting nodes={where content={}{coordinate}{}},
  where level<=1{line width=2pt}{line width=1pt},
  [1 Clustering Ensemble\\Approaches, blur shadow
    [2.1 Generative\\Mechanism
     [3.1 Different\\Algorithms]
     [3.2 Single\\Algorithms
        [4.1 Different built--in\\initialization]
        [
          [4.3 Different subsets\\of features]
          [
            [4.5 Different subsets\\of objects]
          ]
          [4.4 Projecting data\\onto different subspaces]
        ]
        [4.2 Different\\parameters]
      ]
    ]
    [2.2 Consensus\\Function
      [3.3 Information Theory\\Approach]
      [
        [3.5 Voting approach]
        [
          [3.7 Hypergraph\\methods]
        ]
        [3.6 Mixture Model (EM)]
      ]
      [3.4 Co--association\\based approach]
    ]
  ]
\end{forest}
\end{document}

Forest tree - simpler, but more automatised, consistent and flexible code with stylistic variations

| improve this answer | |

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.