这个层次图该如何画?

这个层次图该如何画?

在此处输入图片描述

我只是想知道我应该如何绘制这个图表?我应该使用森林包吗?如果有相应的代码将会很有帮助,提前谢谢。

答案1

作为起点,可以使用库提供以下纯 TikZ 代码arrows.metachains以及positioning

\documentclass[border=3mm,
               multi,
               tikz]{standalone}
\usetikzlibrary{arrows.meta, chains, positioning}

    \begin{document}
\begin{tikzpicture}[
    node distance = 12mm and 2mm,
      start chain = going right,
every node/.style = {draw, inner sep=2mm, align=center,
                     text width=32mm, minimum height=12mm,
                     on chain},
Arr/.style = {-{Straight Barb[length=5pt,width=5pt]},thick}
                    ]
\node (n1) {Data gathering through interviews};
\node (n2) [below=3mm of n1]    {B};
%
\node (n31)[below left=12mm and 2mm of n2]
                                {C1};
\node (n32)                     {C2};
\node (n33)                     {C3};
%
\node (n41)[below left=18mm and 2mm of n31]
                                {D1};
\node (n42)                     {D2};
\node (n43)                     {D3};
\node (n44)                     {D4};
\node (n45)                     {D5};
%
\node (n5) [below=of n43]       {E1};
% arrows
\draw[Arr] (n1) -- (n2);
\foreach \i in {1, 2, 3}    \draw[Arr] (n2.south) -- (n3\i.north);
\foreach \i in {1, 2, 3}
{   \foreach \j in {1,...,5}
    \draw[Arr] (n3\i.south) -- (n4\j.north);
}
\foreach \i in {1,...,5}    \draw[Arr] (n4\i.south) -- (n5.north);
\end{tikzpicture}
    \end{document}

随意编辑上述示例并在节点中添加正确的文本。代码给出的结果与问题中所示的结果类似:

在此处输入图片描述

答案2

chains,循环并可scopes帮助:

\documentclass[tikz,border=10pt,multi]{standalone}
\usetikzlibrary{chains,scopes}
\begin{document}
\begin{tikzpicture}
  [
  start chain=main going below, every on chain/.append style={text width=15mm, text centered, minimum height=7.5mm, draw}, every join/.append style={->}
  ]
  \node [on chain, join] {A};
  \node [on chain, join] {B};
  \node [on chain, join] {C};
  {[start branch=this going right]
    \node [on chain] {F};
    \node [on chain=going below, join] {G};
    \node [on chain=going right] {H};
  }
  {[start branch=that going left]
    \node [on chain] {I};
    \node [on chain=going below, join] {J};
    \node [on chain=going left] {K};
  }
  \node [on chain, join] {D};
  \node [on chain, join] {E};
  \foreach \i in {this,that} \draw [->] (main-2) -- (main/\i-2);
  \foreach \i in {{main/this-4},{main/this-3},main-4,{main/that-3},{main/that-4}}
  {
    \foreach \j in {main-3,{main/this-2},{main/that-2}} \draw [->] (\j.south) -- (\i.north);
    \draw [->] (\i.south) -- (main-5.north);
  }
\end{tikzpicture}
\end{document}

链、作用域和循环

答案3

我的答案不是 TeX 风格,而是我喜欢的方式:使用 inkscape(外部但免费软件)和\includegraphics导出的 pdf。

这种方法的主要优点是,它非常简单易用。如果你不想为了 Tex 而使用 Tex,我会向初学者推荐这种方法。

相关内容