TransWikia.com

Node box in hierarchy chart?

TeX - LaTeX Asked by Electrino on January 24, 2021

So Im trying to make a hierarchy chart in overleaf. Everything was going fine and Im not sure what I changed but the bounding box for each node has disappeared. I was following the example found here. Here’s what I was trying:

documentclass[border=10pt,tikz]{standalone}
usepackage[edges]{forest}
usetikzlibrary{fit}
usetikzlibrary{shadows.blur}

begin{document}
begin{forest}
  for tree={
   grow'=0,
    align=center,
    fill=white, blur shadow
  },
  forked edges,
  [VImp Methods
    [Parametric
      [Linear regression
       [Correlation Coefficient]
       [Normal regression coefficient]
      ]
      [Rank regression
        [Rank correlation coefficient]
        [Standardized rank regression coefficient]
        ]
      ]
    
    [Non-parametirc
     [LOESS]
     [GAM]
     [Random Forest
      [Gini]
      [Permutation]
     ]
    ]
    [Hypothesis test Methods
     [Grid-based
      [Common means test]
      [Statistical Independence test]
     ]
     [Non-grid based
      [Two-dimensional Kolmogorov-Smirnov (KS) test]
      ]
    ]
    [Variance-based methods]
  ]
  node [draw, fit=(current bounding box.south east) (current bounding box.north west)] {};
end{forest}
end{document}

And this produces this:
Hierarchy diagram

How do I add a black rectangle/bounding box around each node?

2 Answers

enter image description here

documentclass[border=10pt,tikz]{standalone}
usepackage[edges]{forest}
usetikzlibrary{fit}
usetikzlibrary{shadows.blur}

begin{document}
    begin{forest}
        for tree={
            grow'=0,
            align=center,draw,
            fill=white, 
            blur shadow,
forked edges,
        },
%       forked edges,
        [VImp Methods
        [Parametric
        [Linear regression
        [Correlation Coefficient]
        [Normal regression coefficient]
        ]
        [Rank regression
        [Rank correlation coefficient]
        [Standardized rank regression coefficient]
        ]
        ]
        %
        [Non-parametirc
        [LOESS]
        [GAM]
        [Random Forest
        [Gini]
        [Permutation]
        ]
        ]
        [Hypothesis test Methods
        [Grid-based
        [Common means test]
        [Statistical Independence test]
        ]
        [Non-grid based
        [Two-dimensional Kolmogorov-Smirnov (KS) test]
        ]
        ]
        [Variance-based methods]
        ]
        node [draw, fit=(current bounding box.south east) (current bounding box.north west)] {}
        ;
    end{forest}
end{document}

Correct answer by js bibra on January 24, 2021

Mostly off-topic suggestions (since your problem is already solved by @js bibra answer, +1) :-). You may liked it:

documentclass[border=10pt]{standalone}
usepackage[edges]{forest}
usetikzlibrary{shadows.blur}

begin{document}
    begin{forest}
for tree={
    draw, semithick, fill=white, blur shadow,
    align=left,
%
    grow'=0,
    anchor = west,
    forked edges,                   % see https://tex.stackexchange.com/a/333597/121799
     edge = {-stealth},
    l sep = 2.5em,
 fork sep = 1.2em,
tier/.option = level,
        }
[VImp Methods
    [Parametric
        [Linear regression
           [Correlation Coefficient]
           [Normal regression coefficient]
        ]
        [Rank regression
            [Rank correlation coefficient]
            [Standardized rank regression coefficient]
        ]
    ]
    [Non-parametirc
        [LOESS]
        [GAM]
        [Random Forest
            [Gini]
            [Permutation]
        ]
    ]
    [Hypothesis test Methods
        [Grid-based
            [Common means test]
            [Statistical Independence test]
        ]
        [Non-grid based
            [Two-dimensional Kolmogorov-Smirnov (KS) test]
        ]
    ]
    [Variance-based methods]
]
node [draw, inner sep=1ex,
       fit=(current bounding box.south east) 
           (current bounding box.north west)] {};
end{forest}
end{document}

enter image description here

Answered by Zarko on January 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP