5

I'm trying to draw the following figure with Tikz. I looked to many answers and examples in tex.StackExchange and texample.net. It took me a lot of time to get it similar to the original figure, I'm looking for a more efficient and professional way to draw this figure any help I will appreciate.

this is the original figure: Original figure

this is my code:

\documentclass[border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, positioning,shadows, shapes}

\definecolor{myblue}{HTML}{bcc9cf}
\definecolor{mygrey}{HTML}{d8dfe2}
\definecolor{mywhite}{HTML}{ffffff}

\tikzset{
    RoundedRect/.style={draw, very thick, minimum width=8em, minimum height=8ex, inner ysep=2mm, outer sep=1pt, execute at end node=\vphantom{g},font=\Huge,drop shadow, rounded corners},
    SignalToEast/.style={RoundedRect, inner xsep=-2pt,signal, signal to= east},
    SignalToWest/.style={RoundedRect, inner xsep=-2pt,signal, signal to= west},     
    TextBox/.style={font=\scriptsize\bfseries,  align=center,text width= 2cm},
    smallRect/.style={very thick,draw,rectangle,blue},
    smallElli/.style={very thick,draw,ellipse,red}
}   

\begin{document}
    \begin{tikzpicture}[node distance = 10mm and 20mm]
    \node (1) [SignalToEast,fill=myblue] {1};
    \node (2) [RoundedRect,fill=mygrey,above right=of 1] {2};
    \node (3) [RoundedRect,fill=mygrey,below right=of 1] {3};
    \node (4) [SignalToWest,fill=myblue,below right=of 2] {4};
    \node (5) [left=2cm of 1] {};
    \node (6) [right=3.5cm of 4] {};            
    \node (7) [TextBox,below =1.5cm of 1.south west] {Description of this node};
    \node (8) [TextBox,below=.5cm of 4.south east] {Description of this node};
        
    % Some auxiliary coordinates for nodNam13 arrows 
    \node (coordNam1) [below=.1mm of 5.south] {};
    
    \node (aux1) [smallRect,right=15mm of coordNam1,inner sep=1.5pt] {7};
    \node (aux2) [smallRect,right=11mm of coordNam1,inner sep=1.5pt] {8};
    \node (aux3) [smallElli,right=6mm of coordNam1,inner sep=1pt] {7};
    \node (aux3) [right=1mm of coordNam1,inner sep=1pt] {$\ldots$};
    %--------------------------------------------------------------------------------
    \node (coord1) [right=of 4.10] {};
    
    \node (COORD1) [right=.5cm of coord1,inner sep=1pt,blue,yshift=1mm] {$\mathcal{F(\omega}^x_1)$};
    \node (COORD2) [right=-.5cm of coord1,inner sep=1pt,blue,yshift=1mm] {$\mathcal{F(\omega}^y_1)$};
    \node (COORD3) [right=-1.5cm of coord1,inner sep=1pt,red,yshift=1mm] {$\mathcal{F(\omega}^x_2)$};
    \node (COORD4) [right=-2cm of coord1,inner sep=1pt,yshift=.5mm] {$\ldots$};
    %--------------------------------------------------------------------------------
    \node (3coord1) [left=0mm of 3.north west,inner sep=0pt] {};
        
    \node (3COORD1) [smallElli,left=4mm of 3coord1,inner sep=1pt] {4};
    \node (3COORD2) [smallElli,left=8mm of 3coord1,inner sep=1pt] {5};
    \node (3COORD3) [smallElli,left=12mm of 3coord1,inner sep=1pt] {6};
    \node (3COORD4) [left=16mm of 3coord1,inner sep=1pt] {$\mathcal{\omega}^y_4$};
    
    \node (3COORD1) [smallRect,left=4mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {4};
    \node (3COORD2) [smallRect,left=8mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {5};
    \node (3COORD3) [smallRect,left=12mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {6};
    \node (3COORD4) [left=16mm of 3coord1,inner sep=1pt,yshift=-6mm] {$\mathcal{\omega}^y_4$};
    
    \node (3COORD1) [smallElli,left=1mm of 3coord1,inner sep=1pt,yshift=-13mm] {2};
    \node (3COORD2) [smallElli,left=5mm of 3coord1,inner sep=1pt,yshift=-13mm] {3};
    \node (3COORD3) [smallElli,left=9mm of 3coord1,inner sep=1pt,yshift=-13mm] {4};
    \node (3COORD4) [left=13mm of 3coord1,inner sep=1pt,yshift=-13mm] {$\mathcal{\omega}^y_2$};
    
    \node (3COORD1) [smallRect,left=1mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {2};
    \node (3COORD2) [smallRect,left=5mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {3};
    \node (3COORD3) [smallRect,left=9mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {4};
    \node (3COORD4) [left=13mm of 3coord1,inner sep=1pt,yshift=-18mm] {$\mathcal{\omega}^x_2$};
    
    %******************************************************************************
    \node (below4) [below= 1mm of 4] { };
    \node (FW1) [left=2mm of below4,inner sep=.5pt] {$\mathcal{F(\omega}^x_2)$};
    
    \node (FW2) [left=6mm of below4,inner sep=.5pt,yshift=-5mm] {$\mathcal{F(\omega}^y_2)$};
    
    \node (FW3) [left=11mm of below4,inner sep=.5pt,yshift=-9mm] {$\mathcal{F(\omega}^x_4)$};
    
    \node (FW4) [left=16mm of below4,inner sep=.5pt,yshift=-14mm] {$\mathcal{F(\omega}^y_4)$};
    %******************************************************************************
    
    \draw[circle,below=2mm of coordNam1] (5.east |- 1.west);
    \draw[-latex,very thick] (1) -- (2);
    \draw[-Stealth,very thick] (1) -- (3);
    \draw[-latex,very thick] (3) -- (4);
    \draw[-latex,very thick] (2) -- (4);
    \draw[-latex,very thick] (5) -- (1);
    \draw[-latex,very thick] (4) -- (6);
    \draw[dash dot,very thick] (8) -- (4.text);
    %-------------------------------------------------------------------------------
    \node (darect) [draw=blue, very thick, minimum width=5.5em, minimum height=8ex, inner ysep=2mm, outer sep=1pt,below =3mm of 1.center,dashed,rounded corners] {};
    
    \node (x1) [smallRect,below=3.5mm of 1.south east,xshift=-5mm,fill=mywhite,inner sep=1.5pt] {4};
    \node (x2) [smallRect,below=3.5mm of 1.south,fill=mywhite,inner sep=1.5pt] {5};
    \node (x3) [smallRect,below=3.5mm of 1.south west,xshift=5mm,fill=mywhite,inner sep=1.5pt] {6};
    
    \node (xx1) [smallElli,below=-2mm of 1.south east,xshift=-5mm,fill=mywhite,inner sep=1pt] {4};
    \node (xx2) [smallElli,below=-2mm of 1.south,fill=mywhite,inner sep=1pt] {5};
    \node (xx3) [smallElli,below=-2mm of 1.south west,xshift=5mm,fill=mywhite,inner sep=1pt] {6};
    
    \draw[dash dot,very thick] (7) -- (darect);
    \end{tikzpicture}

\end{document}

enter image description here

I'm looking for a technique to position and connect nodes without trying many times. In my code, I changed the position of nodes with mm until I put it in the proper location. Is there a method to do it without trying different values?

2
  • Welcome to tex,sx. Jul 11, 2022 at 19:08
  • 3
    What you did is already of good quality. You may want to look for chains to simplify your red and blue labels. And you should use the same arrow tip everywhere. If you want to be more precise with your arrows, you can try this: \draw[-latex,very thick] (1) -- (2.west); and create an arrow style with shorten to give space between your arrows and your nodes.
    – SebGlav
    Jul 11, 2022 at 20:56

1 Answer 1

1

You have made a very good initial effort, I just have some small improvements to your MWE.

  1. I have noticed that you use too many nodes. I have grouped many of them by defining new commands \smallElli and \smallRect.
  2. I have replaced \mathcal{\omega} with \omega (they give the same result).
  3. I have introduced a command \myF for \mathcal{F}
  4. I have put the text along the arrow from nodes 3 to 4 using nodes along the draw operation.

Hope this helps!

\documentclass[border=10pt]{standalone}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{arrows, arrows.meta, positioning,shadows, shapes}

\definecolor{myblue}{HTML}{bcc9cf}
\definecolor{mygrey}{HTML}{d8dfe2}
\definecolor{mywhite}{HTML}{ffffff}

\tikzset{
    RoundedRect/.style={draw, very thick, minimum width=8em, minimum height=8ex, inner ysep=2mm, outer sep=1pt, execute at end node=\vphantom{g},font=\Huge,drop shadow, rounded corners},
    SignalToEast/.style={RoundedRect, inner xsep=-2pt,signal, signal to= east},
    SignalToWest/.style={RoundedRect, inner xsep=-2pt,signal, signal to= west},     
    TextBox/.style={font=\scriptsize\bfseries,  align=center,text width= 2cm},
    smallRect/.style={very thick,draw,rectangle,blue},
    smallElli/.style={very thick,draw,ellipse,red}
}

\newcommand{\smallElli}[1]{\tikz{\node[ellipse,draw=red,fill=white,solid,very thick,inner sep=1pt]{{\color{red}#1}};}}
\newcommand{\smallRect}[1]{\tikz{\node[rectangle,draw=blue,fill=white,solid,very thick,inner sep=2pt,rounded corners=0pt]{{\color{blue}#1}};}}
\newcommand{\myF}{\ensuremath{\mathcal{F}}}

\begin{document}
    \begin{tikzpicture}[node distance = 10mm and 20mm]
        \node (1) [SignalToEast,fill=myblue] {1};
        \node (2) [RoundedRect,fill=mygrey,above right=of 1] {2};
        \node (3) [RoundedRect,fill=mygrey,below right=of 1] {3};
        \node (4) [SignalToWest,fill=myblue,below right=of 2] {4};
        \node (5) [left=2cm of 1] {};
        \node (6) [right=3.5cm of 4] {};            
        \node (7) [TextBox,below =1.5cm of 1.south west] {Description of this node};
        \node (8) [TextBox,below=.5cm of 4.south east] {Description of this node};
        
        % Some auxiliary coordinates for nodNam13 arrows 
        \node (coordNam1) [below=.1mm of 5.south] {};
        
%        \node (aux1) [smallRect,right=15mm of coordNam1,inner sep=1.5pt] {7};
%        \node (aux2) [smallRect,right=11mm of coordNam1,inner sep=1.5pt] {8};
%        \node (aux3) [smallElli,right=6mm of coordNam1,inner sep=1pt] {7};
%        \node (aux3) [right=1mm of coordNam1,inner sep=1pt] {$\ldots$};
        \node [below=1pt of 5,anchor=north west,inner sep=0pt, baseline=0pt] {$\ldots$ \smallElli{7} \smallRect{8} \smallRect{7}};
        %--------------------------------------------------------------------------------
%        \node (coord1) [right=of 4.10] {};
%        
%        \node (COORD1) [right=.5cm of coord1,inner sep=1pt,blue,yshift=1mm] {$\mathcal{F(\omega}^x_1)$};
%        \node (COORD2) [right=-.5cm of coord1,inner sep=1pt,blue,yshift=1mm] {$\mathcal{F(\omega}^y_1)$};
%        \node (COORD3) [right=-1.5cm of coord1,inner sep=1pt,red,yshift=1mm] {$\mathcal{F(\omega}^x_2)$};
%        \node (COORD4) [right=-2cm of coord1,inner sep=1pt,yshift=.5mm] {$\ldots$};
        \node [above right = 1pt and 1pt of 4.east] {$\ldots {\color{red} \myF(\omega_2^x)} {\color{blue} \myF(\omega_1^y) \myF(\omega_1^x)}$};
        %--------------------------------------------------------------------------------
%        \node (3coord1) [left=0mm of 3.north west,inner sep=0pt, anchor=south west] {};
        
%        \node (3COORD1) [smallElli,left=4mm of 3coord1,inner sep=1pt] {4};
%        \node (3COORD2) [smallElli,left=8mm of 3coord1,inner sep=1pt] {5};
%        \node (3COORD3) [smallElli,left=12mm of 3coord1,inner sep=1pt] {6};
%        \node (3COORD4) [left=16mm of 3coord1,inner sep=1pt] {$\mathcal{\omega}^y_4$};
        
%        \node (3COORD1) [smallRect,left=4mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {4};
%        \node (3COORD2) [smallRect,left=8mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {5};
%        \node (3COORD3) [smallRect,left=12mm of 3coord1,inner sep=1.5pt,yshift=-6mm] {6};
%        \node (3COORD4) [left=16mm of 3coord1,inner sep=1pt,yshift=-6mm] {$\mathcal{\omega}^y_4$};
        \node [below left = 1.25em and 3em of 3.west,anchor=south east,align=center,inner sep=0pt] {$\omega_4^y$ \smallElli{6} \smallElli{5} \smallElli{4}\\$\omega_4^x$ \smallRect{6} \smallRect{5} \smallRect{4}};
        
%        \node (3COORD1) [smallElli,left=1mm of 3coord1,inner sep=1pt,yshift=-13mm] {2};
%        \node (3COORD2) [smallElli,left=5mm of 3coord1,inner sep=1pt,yshift=-13mm] {3};
%        \node (3COORD3) [smallElli,left=9mm of 3coord1,inner sep=1pt,yshift=-13mm] {4};
%        \node (3COORD4) [left=13mm of 3coord1,inner sep=1pt,yshift=-13mm] {$\mathcal{\omega}^y_2$};
        
%        \node (3COORD1) [smallRect,left=1mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {2};
%        \node (3COORD2) [smallRect,left=5mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {3};
%        \node (3COORD3) [smallRect,left=9mm of 3coord1,inner sep=1.5pt,yshift=-18mm] {4};
%        \node (3COORD4) [left=13mm of 3coord1,inner sep=1pt,yshift=-18mm] {$\mathcal{\omega}^x_2$};

        \node [below left = 1em and 0.25em of 3.west,anchor=north east,align=center] {$\omega_2^y$ \smallElli{4} \smallElli{3} \smallElli{2}\\$\omega_2^x$ \smallRect{4} \smallRect{3} \smallRect{2}};
        
        %******************************************************************************
%        \node (below4) [below= 1mm of 4] { };
%        \node (FW1) [left=2mm of below4,inner sep=.5pt] {$\mathcal{F(\omega}^x_2)$};
%        
%        \node (FW2) [left=6mm of below4,inner sep=.5pt,yshift=-5mm] {$\mathcal{F(\omega}^y_2)$};
%        
%        \node (FW3) [left=11mm of below4,inner sep=.5pt,yshift=-9mm] {$\mathcal{F(\omega}^x_4)$};
%        
%        \node (FW4) [left=16mm of below4,inner sep=.5pt,yshift=-14mm] {$\mathcal{F(\omega}^y_4)$};
        %******************************************************************************
        
        \tikzstyle{temp} = [below=1em, inner sep=0pt, anchor=north west]
        \draw[circle,below=2mm of coordNam1] (5.east |- 1.west);
        \draw[-latex,very thick] (1) -- (2);
        \draw[-Stealth,very thick] (1) -- (3);
        \draw[-latex,very thick] (3) -- node [pos=0.1, temp] {$\myF(\omega_4^y)$} node [pos=0.4, temp] {$\myF(\omega_4^x)$} node [pos=0.7, temp] {$\myF(\omega_2^y)$} node [pos=1, temp] {$\myF(\omega_2^x)$} (4);
        \draw[-latex,very thick] (2) -- (4);
        \draw[-latex,very thick] (5) -- (1);
        \draw[-latex,very thick] (4) -- (6);
        \draw[dash dot,very thick] (8) -- (4.text);
        %-------------------------------------------------------------------------------
        \node (darect) [rectangle, draw=blue, dashed, rounded corners, very thick, below = 3mm of 1.center, align=center] {\smallElli{6} \smallElli{5} \smallElli{4}\\ \smallRect{6} \smallRect{5} \smallRect{4}};
        
%        \node (x1) [smallRect,below=3.5mm of 1.south east,xshift=-5mm,fill=mywhite,inner sep=1.5pt] {4};
%        \node (x2) [smallRect,below=3.5mm of 1.south,fill=mywhite,inner sep=1.5pt] {5};
%        \node (x3) [smallRect,below=3.5mm of 1.south west,xshift=5mm,fill=mywhite,inner sep=1.5pt] {6};
%        
%        \node (xx1) [smallElli,below=-2mm of 1.south east,xshift=-5mm,fill=mywhite,inner sep=1pt] {4};
%        \node (xx2) [smallElli,below=-2mm of 1.south,fill=mywhite,inner sep=1pt] {5};
%        \node (xx3) [smallElli,below=-2mm of 1.south west,xshift=5mm,fill=mywhite,inner sep=1pt] {6};
        
        \draw[dash dot,very thick] (7) -- (darect);
    \end{tikzpicture}
    
\end{document}

Output: enter image description here

Edit

Using the chains library as @SebGlav suggested might be furthermore efficient. I am not proficient with that.

You must log in to answer this question.