10

Would like to include PRISMA flowchart in my study and I might need help on setting up my tikzpicture commands. Any help is much appreciated. Thanks

enter image description here

1
  • 4
    What did you try until now? I presume you already looked for flow chart in TeX.SX and I'm sure you found a lot of information. So, what's your particular question?
    – Ignasi
    Commented Aug 29, 2015 at 8:00

2 Answers 2

13

Here is a possible solution using the tikz positioning and chains libraries:

enter image description here

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

\begin{document}

\tikzset{
    mynode/.style={
        draw, rectangle, align=center, text width=5cm, font=\small, inner sep=3ex},
    mylabel/.style={
        draw, rectangle, align=center, rounded corners, font=\small\bf, inner sep=2ex, 
        fill=cyan!30, minimum height=3.8cm},
    arrow/.style={
        very thick,->,>=stealth}
}

\begin{tikzpicture}[
    node distance=1.5cm,
    start chain=1 going below,
    every join/.style=arrow,
    ]
    % the chain in the center going below
    \coordinate[on chain=1] (tc);
    \node[mynode, on chain=1] (n2)
        {\# of records after duplicates removed};
    \node[mynode, join, on chain=1] (n3)
        {\# of records screened};
    \node[mynode, join, on chain=1] (n4)
        {\# of full-text articles accessed for eligbility};
    \node[mynode, join, on chain=1] (n5)
        {\# of studies included in qualitative synthesis};
    \node[mynode, join, on chain=1] (n6)
        {\# of studies included in quantitative sysntesis\\ (meta-analysis)};

    % the branches to the right
    \begin{scope}[start chain=going right]
        \chainin (n3);
        \node[mynode, join, on chain]
            {\# of records excluded};
        \chainin (n4);
        \node[mynode, join, on chain]
            {\# of full-text articles excluded, with reasons};
    \end{scope}

    % the nodes at the top  
    \node[mynode, left=1cm of tc, anchor=south east] (n1l)
        {\# of records is identified through database searching};
    \node[mynode, right=1cm of tc, anchor=south west] (n1r) 
        {\# of additional records indentified\\ through other sources};

    \coordinate (n2nl) at ([xshift=-2cm]n2.north);
    \coordinate (n2nr) at ([xshift= 2cm]n2.north);
    \draw[arrow] (n1l.south -| n2nl) -- (n2nl);
    \draw[arrow] (n1r.south -| n2nr) -- (n2nr);

    % the labels on the left
    \begin{scope}[start chain=going below, xshift=-8cm, node distance=.8cm]
        \node[mylabel, on chain] {\rotatebox{90}{Identification}};
        \node[mylabel, on chain] {\rotatebox{90}{Screening}};
        \node[mylabel, on chain] {\rotatebox{90}{Eligibility}};
        \node[mylabel, on chain] {\rotatebox{90}{Included}};
    \end{scope}

    % the title
    \node[above=2.5cm of tc, font=\bf] {PRISMA 2009 Flow Diagram};
\end{tikzpicture}
\end{document}
0
8

Slightly modified (simplyfied) @Sergej solution:

\documentclass[border=2mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{positioning,chains}

\begin{document}

\begin{tikzpicture}[
    node distance=15mm and 10mm,
    start chain=going below,
 mynode/.style = {
        draw, rectangle, align=center, text width=5cm,
        font=\small, inner sep=3ex, outer sep=0pt,
        on chain},
mylabel/.style = {
        draw, rectangle, align=center, rounded corners, 
        font=\small\bfseries, inner sep=2ex, outer sep=0pt,
        fill=cyan!30, minimum height=38mm,
        on chain},
every join/.style = arrow,
     arrow/.style = {very thick,-stealth}
                    ] 
\coordinate (tc);
% the title
\node[above=of tc,font=\bfseries] {PRISMA 2009 Flow Diagram};
% the nodes at the top
\node (n1a) [mynode, left=of tc]    {\# of records is identified 
                                        through database searching};
\node (n1b) [mynode,right=of tc]    {\# of additional records indentified\\
                                        through other sources};
    % the chain in the center
\node (n2)  [mynode, below=of tc]   {\# of records after duplicates removed};
\node (n3)  [mynode,join]   {\# of additional records indentified\\
                                        through other sources};
\node (n4)  [mynode,join]   {\# of full-text articles accessed 
                                            for eligibility};
\node (n5)  [mynode,join]   {\# of studies included in qualitative synthesis};
\node (n6)  [mynode,join]   {\# of studies included in quantitative syntesis\\
                                (meta-analysis)};
% the branches to the right
\node (n3r) [mynode,right=of n3]    {\# of records excluded};
\node (n4r) [mynode,right=of n4]    {\# of full-text articles excluded,
                                        with reasons};
% lines not included in join                                        
\draw[arrow] ([xshift=+22mm] n1a.south) coordinate (a)
                                       -- (a |- n2.north);
\draw[arrow] ([xshift=-22mm] n1b.south) coordinate (b)
                                       -- (b |- n2.north);
\draw[arrow] (n3) -- (n3r);
\draw[arrow] (n4) -- (n4r);
% the labels on the left
    \begin{scope}[node distance=7mm]
\node[mylabel,below left=-3mm and 11mm of n1a.north west]
                {\rotatebox{90}{Identification}};
\node[mylabel]  {\rotatebox{90}{Screening}};
\node[mylabel]  {\rotatebox{90}{Eligibility}};
\node[mylabel]  {\rotatebox{90}{Included}};
    \end{scope}
\end{tikzpicture}
\end{document}

enter image description here

Addendum:
Scaling above image is not straightforward, since design and positioning of labels in blue boxes are accommodated to sizes of the used noded distance and height of nodes.

This can dependency can be a bit reduced by the following code changes (in code are marked by <--)

\documentclass[border=2mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{positioning,
                calc, 
                chains}

\begin{document}

\begin{tikzpicture}[
    node distance=5mm and 10mm,
    start chain=going below,
 mynode/.style = {
        draw, rectangle, align=center, 
        minimum height=\mh,             % <---
        text width=5cm,
        font=\small, outer sep=0pt},
ml/.style args = {#1/#2}{
        draw, rectangle, align=center, rounded corners,
        font=\small\bfseries, inner sep=2ex, outer sep=0pt,
        fill=cyan!30,
        minimum height=1.6*\mh,     % <---
        left=11mm of #2},
every join/.style = arrow,
     arrow/.style = {very thick,-stealth}
                    ]
\def\mh{12ex}                       % <---
\coordinate (tc);
% the nodes at the top
\node (n1a) [mynode, left=of tc]    {\# of records is identified
                                        through database searching};
\node (n1b) [mynode,right=of tc]    {\# of additional records indentified\\
                                        through other sources};
% the title
\node[above=of tc |- n1a.north,font=\bfseries] {PRISMA 2009 Flow Diagram};  % <---
% the chain in the center
    \begin{scope}[nodes={mynode,on chain, join}]
\node (n2)  [below=of tc |- n1a.south]                                      % <--- 
            {\# of records after duplicates removed};
\node (n3)  {\# of additional records indentified\\
             through other sources};
\node (n4)  {\# of full-text articles accessed
             for eligibility};
\node (n5)  {\# of studies included in qualitative synthesis};
\node (n6)  {\# of studies included in quantitative sysntesis\\
             (meta-analysis)};
    \end{scope}
% the branches to the right
\node (n3r) [mynode,right=of n3]    {\# of records excluded};
\node (n4r) [mynode,right=of n4]    {\# of full-text articles excluded,
                                        with reasons};
% lines not included in join
\draw[arrow] ([xshift=+22mm] n1a.south) coordinate (a)
                                       -- (a |- n2.north);
\draw[arrow] ([xshift=-22mm] n1b.south) coordinate (b)
                                       -- (b |- n2.north);
\draw[arrow] (n3) -- (n3r);
\draw[arrow] (n4) -- (n4r);
% the labels on the left
\node[ml=1.5*11ex/n1a.west] {\rotatebox{90}{Identification}};               % <---
\node[ml=28mm/n1a.west|- {$(n2)!0.5!(n3)$}] {\rotatebox{90}{Screening}};    % <---
\node[ml=28mm/n1a.west|- {$(n4)!0.5!(n5)$}] {\rotatebox{90}{Eligibility}};  % <---
\node[ml=1.5*11ex/n1a.west|- n6] {\rotatebox{90}{Included}};                % <---
\end{tikzpicture}
\end{document}

enter image description here

In the case, that someone is interested for flowchart without labels on the left, that MWE can be quite simplified:

\documentclass[border=2mm,
               tikz,
               preview]{standalone}
\usetikzlibrary{positioning,
                chains}

\begin{document}

\begin{tikzpicture}[
    node distance=5mm and 10mm,
    start chain=going below,
 mynode/.style = {
        draw, rectangle, align=center, 
        minimum height=\mh,             % <---
        text width=5cm,
        font=\small, outer sep=0pt},
every join/.style = arrow,
     arrow/.style = {very thick,-stealth}
                    ]
\def\mh{9ex}                            % <---
\coordinate (tc);
% the nodes at the top
\node (n1a) [mynode, left=of tc]    {\# of records is identified
                                        through database searching};
\node (n1b) [mynode,right=of tc]    {\# of additional records indentified\\
                                        through other sources};
% the title
\node[above=of tc |- n1a.north,font=\bfseries] {PRISMA 2009 Flow Diagram};  % <---
% the chain in the center
    \begin{scope}[nodes={mynode,on chain, join}]
\node (n2)  [below=of tc |- n1a.south]                                      % <--- 
            {\# of records after duplicates removed};
\node (n3)  {\# of additional records indentified\\
             through other sources};
\node (n4)  {\# of full-text articles accessed
             for eligibility};
\node (n5)  {\# of studies included in qualitative synthesis};
\node (n6)  {\# of studies included in quantitative sysntesis\\
             (meta-analysis)};
    \end{scope}
% the branches to the right
\node (n3r) [mynode,right=of n3]    {\# of records excluded};
\node (n4r) [mynode,right=of n4]    {\# of full-text articles excluded,
                                        with reasons};
% lines not included in join
\draw[arrow] ([xshift=+22mm] n1a.south) coordinate (a)
                                       -- (a |- n2.north);
\draw[arrow] ([xshift=-22mm] n1b.south) coordinate (b)
                                       -- (b |- n2.north);
\draw[arrow] (n3) -- (n3r);
\draw[arrow] (n4) -- (n4r);
\end{tikzpicture}
\end{document}

enter image description here

8
  • Zarko, have a blessed day
    – user28251
    Commented Aug 29, 2015 at 13:49
  • Both solutions look complicated for me. ;) What is simplified in the second one?
    – buhtz
    Commented Jan 11, 2016 at 19:28
  • 1
    Good question (regarding differences between answers)! As far as I now see, on chain is not repeated in each node in chain. Maybe is in it some more small differences (as stated in answer). If you will read TikZ manual, you will see, that both answers are relatively simple, and in MWE are comments, which explains, to which part of images particular fragment of code belongs. Of course, you can draw this flowchart more directly, without used capabilities of TikZ libraries, which are used in both answers. Consequently code will not be so concise as presented here.
    – Zarko
    Commented Jan 11, 2016 at 19:44
  • I got a bit deeper on both answers here. I don't like them. ;) To much explicite positioning using mm and things like that. I would like to make it more relative and flexible. E.g. The PRISMA-nodes should know themselfs to which of the blue-nodes in the left they belong to.
    – buhtz
    Commented Jan 28, 2016 at 14:31
  • 1
    I will checkyour new question in evening.
    – Zarko
    Commented Jan 28, 2016 at 15:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .