层次结构图中的节点框?

层次结构图中的节点框?

所以我试图在 Overleaf 中制作层次结构图。一切都很顺利,我不确定我做了什么更改,但每个节点的边界框都消失了。我按照示例找到这里。以下是我正在尝试的:

\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}

结果是: 层次结构图

如何在每个节点周围添加黑色矩形/边界框?

答案1

在此处输入图片描述

\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}

答案2

大部分都是题外的建议(因为你的问题已经被 @js bibra 回答解决了,+1):-)。你可能喜欢它:

\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}

在此处输入图片描述

相关内容