尝试重新创建下面的图表。我的一些框重叠或间距不够远。

尝试重新创建下面的图表。我的一些框重叠或间距不够远。

网络图

\documentclass{article}  
\usepackage{tikz}  
\usetikzlibrary{arrows}  
\begin{document}  

\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=3.5cm,
                    thick,main node/.style={rectangle,draw,font=\sffamily\Large\bfseries}]

  \node[main node] (C4) {C4};  
  \node[main node] (IN3M) [left of=C4] {IN3M};  
  \node[main node] (TDC) [right of=C4] {TDC};  
  \node[main node] (C5) [above right of=C4] {C5};  
  \node[main node] (S3M) [right of=C5] {S3M};  
  \node[main node] (P5) [above right of=C5] {P5};   
   \node[main node] (C6) [above of=C4] {C6};  
  \node[main node] (C7) [right of=C6] {C7};  
  \node[main node] (P7) [above right of=C7] {P7};  
  \node[main node] (S1M) [right of=C7] {S1M};  
  \node[main node] (P6) [above of=C6] {P6};  
  \node[main node] (C1) [below of=C4] {C1};  
  \node[main node] (C3) [below of=C1] {C3};  
  \node[main node] (IN1M) [below of=C3] {IN1M};  
  \node[main node] (IN1S2) [below of=IN1M] {IN1S2};  
  \node[main node] (IN1XS2) [below of=IN1S2] {IN1XS2};  
  \node[main node] (IN1XS3) [right of=IN1XS2] {IN1XS3};  
  \node[main node] (IN1S1) [left of=IN1S2] {IN1S1};   
  \node[main node] (IN1XS1) [below of=IN1S1] {IN1XS1};    
  \node[main node] (IN1S3) [right of=IN1S2] {IN1S3};    

\path[every node/.style={font=\sffamily\small}]

  (C4) edge node [left] {EW} (C6)  
       edge node [left] {EW} (C1)  
       edge node [above] {EW} (IN3M)  
       edge node [right] {EW} (C5)  
       edge node [above] {EW} (TDC)

  (C6) edge node [above] {EW} (C7)
  (C6) edge node [left] {EW} (P6)

  (C7) edge node [above] {EW} (S1M)  
       edge node [left] {EW} (P7);  



\end{tikzpicture}  
\end{document}

答案1

像这样?

在此处输入图片描述

在节点定位中使用库positioning。通过它,节点之间的距离由确定node distance。除此之外,这个库还用于arrows.meta箭头、calc计算某些节点的位置、chains在链中定位节点、quotes标记边(存在边的地方)以及shapes.multipart密集连接的节点。

下面的 MWE 并不完整。我留给你的缺失线条的绘制,也是为了检查节点中的文本是否正确。我希望它能成为一个好的起点...

\documentclass{article}
\usepackage[margin=20mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, calc, chains, positioning, quotes, shapes.multipart}

\begin{document}

    \begin{tikzpicture}[
    node distance = 7mm and 9mm,
      start chain = going below,
every edge/.style = {draw, semithick, Stealth-Stealth,
                     shorten <=1pt, shorten >=1pt,
                     font=\footnotesize\sffamily, 
                     inner ysep=1pt, auto},
every label/.append style = {align=center,
                             font=\sffamily\linespread{0.84}\selectfont},
       box/.style = {rectangle, draw,
                     fill=#1,
                     minimum width=12mm, inner sep= 2mm, outer sep=0mm, 
                     font=\small\bfseries\sffamily,
                     on chain},
  mpx/.style args = {#1/#2}{% multi part box
                     rectangle split, draw,
                     rectangle split parts=#1, 
                     fill=green!#2,
                     minimum width=12mm, inner sep= 2mm, outer sep=0mm,
                     font=\small\bfseries\sffamily,
                     on chain}
                    ]
% column 1 
\node (n11) [mpx=3/30]  {\nodepart{one}     S2X51
                         \nodepart{two}     S2X52
                         \nodepart{three}   S2X53};
\node (n12) [mpx=2/30]  {\nodepart{one}     S2X54
                         \nodepart{two}     S2X55};
\node (n13) [mpx=2/30]  {\nodepart{one}     S2X56
                         \nodepart{two}     S2X57};
\node (n14) [box=green!30]                 {S2X57};
    \coordinate[on chain]   (n15);
\node (n16) [mpx=3/30,dashed]  
                        {\nodepart{one}     A2SX1
                         \nodepart{two}     A2SX2
                         \nodepart{three}   A2SX3};
% column 2
\node (n21) [box=green!30,right=of n11]     {S2S1};
\node (n22) [box=green!30,right=of n12]     {S2S2};
\node (n23) [box=green!30,right=of n13]     {S2S3};
\node (n24) [box=green!30,right=of n14]     {S2S4};
\node (n25) [mpx=3/30,dashed, right=of n16]
                        {\nodepart{one}     A2S1
                         \nodepart{two}     A2S2
                         \nodepart{three}   A2S3};
\node (n26) [mpx=2/60]  {\nodepart{one}     N251
                         \nodepart{two}     N252};
% column 3
\node (n31) [box=green!30,right=of $(n22.east)!0.5!(n23.east)$] {S2M};
\node (n32) [box=green!60,right=of n15 -| n24.east]             {IN3M};
\node (n33) [box=green!30,dashed, right=of n25]                 {A2M};
\node (n34) [box=green!60,right=of n26]                         {IN2M};
% column 4: main column
\node (n41) [box=blue!30,above right=of n11.north -| n31.east]  {P6};
\node (n42) [box=orange!30, right=of n31]                   {C6};
\node (n43) [box=orange!30, right=of n32]                   {C4};
\node (n44) [box=orange!30,right=of $(n33.east)!0.5!(n34.east)$]      {C1};
\node (n45) [box=orange!30]                                 {C3};
\node (n46) [box=green!60]                                  {IN1M};
\node (n47) [box=green!60]                                  {IN1S2};
%
\node (n48) [box=green!60,below left =of n47.south east]    {IN1XS2};
\node (n49) [box=green!60,below right=of n47.south west]    {IN1XS3};
% column 5
\node (n51)  [box=orange!30,right=of n42]           {C7};
\node (n52)  [box=orange!30,above right=of n43]     {C5};
\node (n53)  [box=orange!30,right=of n44]           {C2};
% column 6
\node (n61)  [box=blue!30,right=of n41 -| n51.east] {P7};
\node (n62)  [box=green!30,right=of n51]            {S1M};
\node (n63)  [box=green!30,right=of n52]            {S3M};
\node (n64)  [box=green!30,dashed, right=of n53]    {A1M};
% column 7
\node (n71)  [box=yellow!50,
              label=above:{TDC: Theater\\ Distribution\\ Center}, 
              right=of n43 -| n64.east]             {TDC};
\node (n72)  [mpx=2/30,dashed,right=of n64]
                        {\nodepart{one}     A1S1
                         \nodepart{two}     A1S2};
% column 8
\node (n81)  [box=blue!30,
              above right=of n63 -| n71.east]   {PS};
\node (n82)  [box=blue!30,right=of n71]         {PORT};
\node (n83)  [box=blue!30]                      {P1};
% bottom two rows
% column 3'
\node (n491) [box=green!60,left =of n47 -| n34] {IN1S1};
\node (n492) [box=green!60]                     {IN1XS1};
% column 5'
\node (n493) [box=green!60,right=of n47 -| n53] {IN1S3};
\node (n494) [box=green!60]                     {IN1XS4};
% lines 
\path   
% between column 1 and 2
        (n11.one east)      edge  (n21)
        (n11.two east)      edge  (n21)
        (n11.three east)    edge  (n21)
% ...
% between column 2 and 3
        (n21) edge  (n31)
        (n22) edge  (n31)
        (n23) edge  (n31)
        (n24) edge  (n31)
% ...
% between column 3 and 4
        (n31) edge  (n42)
% ...        
% main column
        (n41) edge  (n42)
        (n42) edge  (n43)
        (n43) edge  (n44)
        (n44) edge  (n45)
        (n45) edge["EV"]    (n46)
        (n46) edge["EV"]    (n47)
%
        (n47) edge["EV" ']  (n48)
        (n47) edge["EV"]    (n49)
%
        (n47) edge["EV" ']  (n491)
        (n47) edge["EV"]    (n493)
%
        (n491) edge["EV" '] (n492)
        (n493) edge["EV"]   (n494)
;
\end{tikzpicture}
\end{document}

注意:此图非常大,因此我通过添加包来增加文本宽度geometry,同时减小图像中的字体大小以使节点可以更小。

相关内容