2

I want to draw the graph like this enter image description here. However, I only came this one, enter image description here

it seems so ugly. I am frustrated, can anyone help me to get what I wanted?

My code is given as follows

\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,
                      text width = 280pt, text centered,
                     minimum height = 10pt, outer color = col3out},  
 oellip/.append style = {ellip, 
                      font = \sffamily\bfseries\large, text centered}}
\begin{forest}
 for tree={
  font=\sffamily\bfseries,
  line width=1pt,
  draw=linecol,
  ellip,
  align=center,
  child anchor=north,
  parent anchor=south,
  drop shadow,
  l sep+=12.5pt,
  edge path={
    \noexpand\path[color=linecol, rounded corners=5pt,
      >={Stealth[length=10pt]}, line width=1pt, ->, \forestoption{edge}]
      (!u.parent anchor) -- +(0,-5pt) -|
      (.child anchor)\forestoption{edge label};
    },
  where level={3}{tier=tier3}{},
  where level={0}{l sep-=15pt}{},
  where level={1}{
    if n={1}{
      edge path={
        \noexpand\path[color=linecol, rounded corners=5pt,
          >={Stealth[length=10pt]}, line width=1pt, ->,
          \forestoption{edge}]
          (!u.west) -| (.child anchor)\forestoption{edge label};
        },
    }{
      edge path={
        \noexpand\path[color=linecol, rounded corners=5pt,
          >={Stealth[length=10pt]}, line width=1pt, ->,
          \forestoption{edge}]
          (!u.east) -| (.child anchor)\forestoption{edge label};
        }, 
     }
    }{}, 
  }
   [Dynamic Object, outer color=col3out
    [Senor 1
    [Filter, rect, name=sse1
    ]
  ]
  [Senor 2
    [Filter, rect, name=sse2
    ]
  ]
  [, phantom, calign with current
    [A\\B, phantom
      [Mutli-Sensor Fusion, orect, name=us
        [{Consensus}, oellip
        ]
      ]
    ]
  ]
  [Senor 3
    [Filter, rect, name=sse3
    ]
  ]
  [Senor 4
    [Filter, rect, name=sse4
    ]
  ]
]
  \begin{scope}[color = linecol, rounded corners = 5pt,
    >={Stealth[length=10pt]}, line width=1pt, ->]
    \draw (sse2.south) -- (us.north -| sse2.south);
    \draw (sse3.south) -- (us.north -| sse3.south);
    \coordinate (c1) at ($(sse1.south)!2/5!(sse2.south)$);
    \coordinate (c2) at ($(sse3.south)!2/5!(sse4.south)$);
    \draw (sse1.south) -- +(0,-10pt) -| (us.north -| c1);
    \draw (sse4.south) -- +(0,-10pt) -| (us.north -| c2);
  \end{scope}
\end{forest}
\end{document}
  • I think it looks better than the original, but watch the spelling. – Benjamin McKay Feb 4 '15 at 11:45
  • @BenjaminMcKay Thanks, the following Harish's answer looks much more better than original. Watch my spelling? I do not understand, can you specify? – wayne Feb 4 '15 at 11:53
  • "sensor" rather than "senor". – Benjamin McKay Feb 4 '15 at 11:54
4

May be this:

\documentclass[tikz,border=10pt]{standalone}
\usepackage{verbatim}
\usepackage{forest}
\usetikzlibrary{arrows.meta, shapes.geometric, calc, shadows,fit}

\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,
                      text width = 280pt, text centered,
                     minimum height = 10pt, outer color = col3out},
 oellip/.append style = {ellip,
                      font = \sffamily\bfseries\large, text centered}}
\begin{forest}
 for tree={
  font=\sffamily\bfseries,
  line width=1pt,
  draw=linecol,
  ellip,
  align=center,
  child anchor=north,
  parent anchor=south,
  drop shadow,
  l sep=1cm,
  edge path={
    \noexpand\path[color=linecol, rounded corners=5pt,
      >={Stealth[length=10pt]}, line width=1pt, ->, \forestoption{edge}]
      (!u.parent anchor) -- +(0,-5pt) -|
      (.child anchor)\forestoption{edge label};
    },
  where level={3}{tier=tier3}{},
  where level={0}{l sep-=15pt}{},
  where level={1}{
    if n={1}{
      edge path={
        \noexpand\path[color=linecol, rounded corners=5pt,
          >={Stealth[length=10pt]}, line width=1pt, ->,
          \forestoption{edge}]
          (!u.south) --++(0,-8pt) -| (.child anchor)\forestoption{edge label};
        },
    }{
      edge path={
        \noexpand\path[color=linecol, rounded corners=5pt,
          >={Stealth[length=10pt]}, line width=1pt, ->,
          \forestoption{edge}]
          (!u.south) --++(0,-8pt) -| (.child anchor)\forestoption{edge label};
        },
     }
    }{},
  }
   [Dynamic Object,l sep=1.5cm, outer color=col3out
    [Senor 1,name=senor1,
    [Filter, rect, name=sse1
    ]
  ]
  [Senor 2,name=senor2,
    [Filter, rect, name=sse2
    ]
  ]
  [, phantom, calign with current
    [A\\B, phantom
      [Mutli-Sensor Fusion, orect, name=us
        [{Consensus}, oellip
        ]
      ]
    ]
  ]
  [Senor 3,name=senor3,
    [Filter, rect, name=sse3
    ]
  ]
  [Senor 4,name=senor4,
    [Filter, rect, name=sse4
    ]
  ]
]
  \begin{scope}[color = linecol, rounded corners = 5pt,
    >={Stealth[length=10pt]}, line width=1pt, ->]
    \draw (sse2.south) -- (us.north -| sse2.south);
    \draw (sse3.south) -- (us.north -| sse3.south);
    \coordinate (c1) at ($(sse1.south)!2/5!(sse2.south)$);
    \coordinate (c2) at ($(sse3.south)!3/5!(sse4.south)$);
    \draw (sse1.south) -- +(0,-22pt) -| (us.north -| c1);
    \draw (sse4.south) -- +(0,-22pt) -| (us.north -| c2);
    \node[draw,dash dot,fit=(senor1)(sse4)(senor4),inner ysep=12pt,]{};
    \coordinate (m1) at ($(sse2)!0.5!(senor2)$);
    \coordinate (m2) at ($(senor2)!0.5!(senor3)$);
    \node[scale=3] at (m1-|m2) {.....};
  \end{scope}
\end{forest}
\end{document}

enter image description here

  • First, thank you very much, it's nice. I have another question: I wanna draw "..." between "sensor 2" and "sensor 3" just like the original graph, how to work it out? – wayne Feb 4 '15 at 11:24
  • @WangyanLi If you give names to the 2 phantom nodes, p and q, say, then you can put \node at ($(p)!1/2!(q)$) {\dots}; in the group of drawing commands following the specification of the tree. – cfr Feb 4 '15 at 13:27
  • (+1) I would adjust the dotted rectangle so that the tips of the arrows are within its boundaries and move the curves from the outermost 'Filter' nodes a bit downwards so that the ysep above and below the tree to the dotted lines remains roughly equal. – cfr Feb 4 '15 at 13:31
  • 1
    @cfr Your wish is my command :-) Done. – user11232 Feb 4 '15 at 13:45
  • @HarishKumar Many thanks to you, I have learnt a lot from you! – wayne Feb 4 '15 at 13:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.