如何减少树节点之间的间隙?

如何减少树节点之间的间隙?

有没有选项可以减少节点 3dots 和“Transmission Zone-k”之间的间隙(红色圆圈)?我希望“3dots”节点位于节点“Transmission Zone-2”和“Transmission Zone-k”中间。

我的代码:

\documentclass[tikz,border=10pt]{standalone}

\usepackage{verbatim}
\usepackage{forest}
\usetikzlibrary{arrows.meta, shapes.geometric, calc, shadows}

\colorlet{mygreen}{green!75!black}
\colorlet{col1in}{red!30}
\colorlet{col1out}{red!40}
\colorlet{col2in}{mygreen!40}
\colorlet{col2out}{mygreen!50}
\colorlet{col3in}{blue!30}
\colorlet{col3out}{blue!40}
\colorlet{col4in}{mygreen!20}
\colorlet{col4out}{mygreen!30}
\colorlet{col5in}{blue!10}
\colorlet{col5out}{blue!20}
\colorlet{col6in}{blue!20}
\colorlet{col6out}{blue!30}
\colorlet{col7out}{orange}
\colorlet{col7in}{orange!50}
\colorlet{col8out}{orange!40}
\colorlet{col8in}{orange!20}
\colorlet{linecol}{blue!60}

\begin{document}
\pgfkeys{/forest,
  rect/.append style   = {rectangle, rounded corners = 2pt,
                         inner color = col6in, outer color = col6out},
  ellip/.append style  = {ellipse, inner color = col5in,
                          outer color = col5out},
  orect/.append style  = {rect, font = \sffamily\bfseries\LARGE,
                         text width = 325pt, text centered,
                         minimum height = 10pt, outer color = col7out,
                         inner color=col7in},
  oellip/.append style = {ellip, inner color = col8in, outer color = col8out,
                          font = \sffamily\bfseries\large, text centered}}
\begin{forest}
  for tree={
      line width=1pt,
      draw=linecol,
      ellip,
      align=center,
      parent anchor=south,
      l sep+=15pt,
      outer sep=0pt,
      inner sep=5pt,
      edge path={
        \noexpand\path[color=linecol,
          >={Stealth[length=10pt]}, line width=1pt, -, \forestoption{edge}]
          (!u.parent anchor) -- +(0,-10pt) -|
          (.child anchor)\forestoption{edge label};
        },
      where level={3}{tier=tier3}{},
{},
  }
  [Interconnection,rect, inner color=col2in, outer color=col2out
    [Transmission\\Zone-1,rect, inner color=col2in, outer color=col2out
      [UPV$_1$, rect,inner color=col4in, outer color=col4out]
      [$\cdots$, rect,inner color=col4in, outer color=col4out]
      [UPV$_l$, rect,inner color=col4in, outer color=col4out]
    ]
    [Transmission\\Zone-2, rect, inner color=col2in, outer color=col2out
      [UPV$_1$, rect,inner color=col4in, outer color=col4out
        [Inverter-1, rect, inner color=col4in, outer color=col4out]
        [$\cdots$, rect,inner color=col4in, outer color=col4out]
        [Inverter-y, rect,inner color=col4in, outer color=col4out]
      ]
      [$\cdots$, rect,inner color=col4in, outer color=col4out]
      [UPV$_m$, rect,inner color=col4in, outer color=col4out]
    ]
    [$\hspace{10pt}\cdots\hspace{10pt}$, rect,inner color=col2in, outer color=col2out]
    [Transmission\\Zone-k, rect, inner color=col2in, outer color=col2out
    [Distribution\\Node,rect,inner color=col4in, outer color=col4out
    [DPV$_1$,rect,inner color=col4in, outer color=col4out
    [Inverter-1,rect,inner color=col4in, outer color=col4out]
    [$\cdots$,rect,inner color=col4in, outer color=col4out]
    [Inverter-z,rect,inner color=col4in, outer color=col4out]]
    [$\cdots$,rect,inner color=col4in, outer color=col4out]
    [DPV$_v$,rect,inner color=col4in, outer color=col4out]]
    [UPV$_1$,rect,inner color=col4in, outer color=col4out]
    [$\cdots$,rect,inner color=col4in, outer color=col4out]
    [UPV$_n$,rect,inner color=col4in, outer color=col4out]]
  ]
\end{forest}
\end{document}

图示: 差距

答案1

请注意,不承认你从别人的作品中采用的代码的来源是非常不礼貌的。在这种情况下,你也应该明智地删减那些代码:如果你不想要橙色省略号,为什么要包含这种风格的定义?我无法添加归属,因为我必须搜索来源,我甚至不记得它是我的还是我曾多次使用基于它的 MWE,现在感觉很熟悉了。

这里我还更新了当前森林的代码,这使得这种树更加直观。如果我知道代码的来源,我也可以更新它,但我不知道,所以我不能。

% addaswyd o gôd o gwestiwn Reiso: https://tex.stackexchange.com/q/408737/ - ond yn wreiddiol gan rhywun arall, 'dw i'n sicr
\documentclass[border=10pt]{standalone}
\usepackage[edges]{forest}
\colorlet{mygreen}{green!75!black}
\colorlet{col2in}{mygreen!40}
\colorlet{col2out}{mygreen!50}
\colorlet{col4in}{mygreen!20}
\colorlet{col4out}{mygreen!30}
\colorlet{linecol}{blue!60}

\begin{document}
\pgfkeys{/forest,
  rect/.append style   = {rectangle, rounded corners = 2pt, inner color = col4in, outer color = col4out},
}
\begin{forest}
  forked edges,
  for tree={
    line width=1pt,
    draw=linecol,
    align=center,
    parent anchor=children,
    l sep+=15pt,
    outer sep=0pt,
    inner sep=5pt,
    edge+={color=linecol, line width=1pt},
    fork sep'=10pt,
    where level={3}{tier=tier3}{},
    rect,
  },
  where level<=1{inner color=col2in, outer color=col2out}{},
  [Interconnection
    [Transmission\\Zone-1
      [UPV$_1$]
      [$\cdots$]
      [UPV$_l$]
    ]
    [Transmission\\Zone-2
      [UPV$_1$
        [Inverter-1]
        [$\cdots$]
        [Inverter-y]
      ]
      [$\cdots$]
      [UPV$_m$]
    ]
    [$\hspace{10pt}\cdots\hspace{10pt}$,
      before drawing tree={
        x/.average={x}{p,fake=n,n}
      }
    ]
    [Transmission\\Zone-k
    [Distribution\\Node
    [DPV$_1$
    [Inverter-1]
    [$\cdots$]
    [Inverter-z]]
    [$\cdots$]
    [DPV$_v$]]
    [UPV$_1$]
    [$\cdots$]
    [UPV$_n$]]
  ]
\end{forest}
\end{document}

以兄弟节点为中心的节点

请注意,这仅在有空间的情况下才有效。如果没有空间,您最终会得到重叠节点。

相关内容