Tikz 和在单线树上绘制兄弟姐妹

Tikz 和在单线树上绘制兄弟姐妹

我正在使用 tikz 创建网络图。目前,我在创建一棵树时遇到了困难,我想像下图一样设置它以节省空间。

在此处输入图片描述

1 是父级,连接到图表的不同部分。当我创建其中一个子级时,我会创建一条直线(并有一条直线穿过它们)。就像这张图片一样

在此处输入图片描述

我读过一些 tikz 风格和文档,但找不到最好的方法。

编辑 1:我需要添加更多内容。以下是我所拥有的。

编辑 2:这是完整代码。第一次在 tex.stackexchange 上发帖,抱歉

\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage{pgfpages}
\pgfpagesuselayout{2 on 1}[a4paper,landscape,border shrink=5mm]
\usetikzlibrary{calc,trees,positioning,arrows,chains,shapes.geometric,%
    decorations.pathreplacing,decorations.pathmorphing,shapes,%
    matrix,shapes.symbols}

\begin{document}

\begin{tikzpicture}
     \node {1} [rectangle,draw, sibling distance = 40mm]
        child{node[rectangle,draw] {1a}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.east)}] {node [rectangle,draw,yshift = -20.5mm]{2}}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.east)}]  {node [rectangle, draw, yshift =-30.5mm]{3}}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) |- (\tikzchildnode.east)}]  {node [rectangle, draw,yshift = -40.5mm] {4}}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) -| (\tikzchildnode.east)}]  {node [rectangle, draw,yshift = -50.5mm] {5}}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) -| (\tikzchildnode.east)}]  {node [rectangle, draw,yshift = -60.5mm] {6}}
                        child[grow =
  edge from parent path={(\tikzparentnode.south) -| (\tikzchildnode.east)}]  {node [rectangle, draw,yshift = -70.5mm] {7}}}
        child{node[rectangle, draw] {1b}}
        child{node[rectangle, draw] {2b}}
        child{node[rectangle, draw] {3b}}
        child{node[rectangle, draw] {4b}}
        child{node[rectangle, draw] {5b}};

  \end{tikzpicture}




\end{document}

答案1

你想要这样的东西吗?

圆形文件夹??!!

这是使用forest基于 TikZ 的树木专业绘图包绘制的。

\documentclass[tikz,border=10pt,multi]{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
  for tree={
    draw,
    circle,
    grow=-180,
    edge={thick},
    thick,
    edge path'={%
      (!u.parent anchor) |- (.child anchor)
    }
  },
  for root={
    parent anchor=south,
    delay={%
      prepend={[, phantom, calign with current]}
    }
  }
  [1,
    [2]
    [3]
    [4]
  ]
\end{forest}
\end{document}

相关内容