Diagrama de flujo del algoritmo en tikZ

Diagrama de flujo del algoritmo en tikZ

El siguiente diagrama de flujo consta de bloques que representan datos y funciones, que se ejecutan en el sentido de las agujas del reloj, mientras que fuera de esta serie de bloques hay pasos explicativos. ¿Cómo codificarías esto en LaTeX mientras haces editable el texto tanto en los bloques como en los pasos circundantes? ¿Es Tikz el camino a seguir? Para usar como figura en un artículo de investigación.

ingrese la descripción de la imagen aquí

Respuesta1

El diseño es sencillo, introducir textos es engorroso. Entonces agregué mucho bla bla. Solo necesitas matrices y algunos estilos para sombreado, etc. Para agregar los textos circundantes, coloca el diagrama en a local bounding boxy usa las posiciones verticales u horizontales de los nodos para la ubicación de los textos.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,matrix,patterns.meta,positioning}
\begin{document}
\begin{tikzpicture}[node font=\sffamily,>=Triangle,
    Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
    line width=1.2pt,
    dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
    shorten >=0.5em,shorten <=0.5em},
    Dotted/.default=6,
    mmat/.style={matrix of nodes,nodes in empty cells,
        row sep=-\pgflinewidth,nodes={minimum width=3em,
            draw,anchor=center,
            text depth=0.25ex,text height=0.8em}},
    dotcell/.style={minimum height=4em,path picture={
        \draw[Dotted] (path picture bounding box.north)--
        (path picture bounding box.south);}},
    hatchcell/.style={pattern={Lines[angle=45,distance={3pt}]}},
    vcell/.style={xshift=-1ex,hatchcell},
    block/.style={draw,align=center}    
    ]
 \begin{scope}[local bounding box=diagram]
  \node[mmat] (vmat1) {|[vcell]|1 \\
     2 \\ |[dotcell]|\\  10\\ }; 
  %
  \node[mmat,below=2em of vmat1] (vmat2) {1 \\
     |[vcell]| 2 \\ |[dotcell]|\\  10\\ };   
  %
  \node[mmat,below=3em of vmat2] (vmat3) {1 \\
     2 \\ |[dotcell]|\\  |[vcell]|  10\\ };  
  %  
  \foreach \X in {1,2,3}
  {\node[right=3em of vmat\X,block](b\X){regression\textsubscript{a}\\
     regression\textsubscript{b}\\ regression\textsubscript{c}};
  \draw[->] (vmat\X-3-1.east|-b\X) -- (b\X);}
  %
  \node[right=3em of b1.south east,anchor=south west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat1) {
   1 & $Z_{1\mathsf{a}}$ & $Z_{1\mathsf{b}}$ & $Z_{1\mathsf{c}}$ \\
   2 & $Z_{2\mathsf{a}}$ & $Z_{2\mathsf{b}}$ & $Z_{2\mathsf{c}}$ \\
  }; 
  \draw[->] (b1.east|-hmat1-1-1.west) -- (hmat1-1-1.west);
  %
  \node[right=3em of b2.north east,anchor=north west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat2) {
   10 & $Z_{10\mathsf{a}}$ & $Z_{10\mathsf{b}}$ & $Z_{10\mathsf{c}}$ \\
  }; 
  \foreach \X [count=\Y] in {a,b,c}
  {\node[below=\Y*2em of hmat2-1-\the\numexpr\Y+1\relax,block] 
     (CV\Y) {CV Risk\textsubscript{\X}};
  \draw[->] (hmat2-1-\the\numexpr\Y+1\relax) -- (CV\Y); }
  \draw (CV1.west) -- ++ (-1ex,0) |- (CV3);
  \draw[->] (b2.east) -- ++(1em,0) |- (hmat1-2-1.west);
  \draw[->] (b3.east) -- ++(2em,0) |- (hmat2-1-1.west);
  %
  \node[block,below=12em of hmat2](F){Family of weighted\\
     combinations}; 
  \draw[->] (CV2.south-|F) -- (F);
  %
  \node[block,below=4em of F.south west,xshift=-3em] (P)
  {Some long formula with P}; 
  \draw[<-] (P.east) -- ++ (1em,0) coordinate (aux) -- (F.south-|aux);
  \node[block,left=3em of P,text width=8em] (PP)  {\vphantom{P}}; 
  \draw[->] (P) -- (PP);
  %
  \node[left=3em of vmat2.north west,block] (A){Collection of\\ algorithms}; 
  \node[left=3em of vmat2.south west,block] (MD){Mortality\\ data};  
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat1-3-1);
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat3-3-1);
  \draw[->] (MD.east) -- ++ (1.2em,0) |- (vmat2-3-1);
  \path (current bounding box.south west) + (-1ex,-1ex)
  (current bounding box.north east) + (1ex,1ex);
 \end{scope} 
 \node[text width=7em,above] at (MD|-diagram.north){1.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (vmat1|-diagram.north){2.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (b1|-diagram.north){3.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=12em,above] at (hmat1|-diagram.north){4.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (hmat2-|diagram.east){5.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (F-|diagram.east){6.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (P|-diagram.south){7.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (PP|-diagram.south){8.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
\end{tikzpicture}
\end{document}

ingrese la descripción de la imagen aquí

Esta es una versión que funciona en (algunas de las) instalaciones TeX obsoletas.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta,matrix,patterns,positioning}
\begin{document}
\begin{tikzpicture}[node font=\sffamily,>=Triangle,
    Dotted/.style={% https://tex.stackexchange.com/a/52856/194703
    line width=1.2pt,
    dash pattern=on 0.01\pgflinewidth off #1\pgflinewidth,line cap=round,
    shorten >=0.5em,shorten <=0.5em},
    Dotted/.default=6,
    mmat/.style={matrix of nodes,nodes in empty cells,
        row sep=-\pgflinewidth,nodes={minimum width=3em,
            draw,anchor=center,
            text depth=0.25ex,text height=0.8em}},
    dotcell/.style={minimum height=4em,path picture={
        \draw[Dotted] (path picture bounding box.north)--
        (path picture bounding box.south);}},
    hatchcell/.style={pattern=north east lines},
    vcell/.style={xshift=-1ex,hatchcell},
    block/.style={draw,align=center}    
    ]
 \begin{scope}[local bounding box=diagram]
  \node[mmat] (vmat1) {|[vcell]|1 \\
     2 \\ |[dotcell]|\\  10\\ }; 
  %
  \node[mmat,below=2em of vmat1] (vmat2) {1 \\
     |[vcell]| 2 \\ |[dotcell]|\\  10\\ };   
  %
  \node[mmat,below=3em of vmat2] (vmat3) {1 \\
     2 \\ |[dotcell]|\\  |[vcell]|  10\\ };  
  %  
  \foreach \X in {1,2,3}
  {\node[right=3em of vmat\X,block](b\X){regression\textsubscript{a}\\
     regression\textsubscript{b}\\ regression\textsubscript{c}};
  \draw[->] (vmat\X-3-1.east|-b\X) -- (b\X);}
  %
  \node[right=3em of b1.south east,anchor=south west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat1) {
   1 & $Z_{1\mathsf{a}}$ & $Z_{1\mathsf{b}}$ & $Z_{1\mathsf{c}}$ \\
   2 & $Z_{2\mathsf{a}}$ & $Z_{2\mathsf{b}}$ & $Z_{2\mathsf{c}}$ \\
  }; 
  \draw[->] (b1.east|-hmat1-1-1.west) -- (hmat1-1-1.west);
  %
  \node[right=3em of b2.north east,anchor=north west,mmat,
     column 1/.style={nodes={hatchcell}}] (hmat2) {
   10 & $Z_{10\mathsf{a}}$ & $Z_{10\mathsf{b}}$ & $Z_{10\mathsf{c}}$ \\
  }; 
  \foreach \X [count=\Y] in {a,b,c}
  {\node[below=\Y*2em of hmat2-1-\the\numexpr\Y+1\relax,block] 
     (CV\Y) {CV Risk\textsubscript{\X}};
  \draw[->] (hmat2-1-\the\numexpr\Y+1\relax) -- (CV\Y); }
  \draw (CV1.west) -- ++ (-1ex,0) |- (CV3);
  \draw[->] (b2.east) -- ++(1em,0) |- (hmat1-2-1.west);
  \draw[->] (b3.east) -- ++(2em,0) |- (hmat2-1-1.west);
  %
  \node[block,below=12em of hmat2](F){Family of weighted\\
     combinations}; 
  \draw[->] (CV2.south-|F) -- (F);
  %
  \node[block,below=4em of F.south west,xshift=-3em] (P)
  {Some long formula with P}; 
  \draw[<-] (P.east) -- ++ (1em,0) coordinate (aux) -- (F.south-|aux);
  \node[block,left=3em of P,text width=8em] (PP)  {\vphantom{P}}; 
  \draw[->] (P) -- (PP);
  %
  \node[left=3em of vmat2.north west,block] (A){Collection of\\ algorithms}; 
  \node[left=3em of vmat2.south west,block] (MD){Mortality\\ data};  
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat1-3-1);
  \draw[->] (A.east) -- ++ (1.2em,0) |- (vmat3-3-1);
  \draw[->] (MD.east) -- ++ (1.2em,0) |- (vmat2-3-1);
  \path (current bounding box.south west) + (-1ex,-1ex)
  (current bounding box.north east) + (1ex,1ex);
 \end{scope} 
 \node[text width=7em,above] at (MD|-diagram.north){1.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (vmat1|-diagram.north){2.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=7em,above] at (b1|-diagram.north){3.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=12em,above] at (hmat1|-diagram.north){4.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (hmat2-|diagram.east){5.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
  bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=8em,right] at (F-|diagram.east){6.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (P|-diagram.south){7.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
 \node[text width=9em,below] at (PP|-diagram.south){8.\ bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla
 bla bla};
\end{tikzpicture}
\end{document}

información relacionada