Skip to content

Instantly share code, notes, and snippets.

@tbrittoborges
Last active July 21, 2016 15:04
Show Gist options
  • Save tbrittoborges/952b1dbe9194ec3e99eaa6136e4b958a to your computer and use it in GitHub Desktop.
Save tbrittoborges/952b1dbe9194ec3e99eaa6136e4b958a to your computer and use it in GitHub Desktop.
example of a flow diagram with latex tikzpicture
\documentclass{article}
\usepackage{tikz}
\usepackage{array}
\usepackage{siunitx}
\usetikzlibrary{shapes.geometric, shapes.misc, arrows, fit, calc}
\newcommand\addvmargin[1]{
\node[fit=(current bounding box),inner ysep=#1,inner xsep=0]{};
}
\tikzstyle{data} = [rectangle, rounded corners, minimum width=3.5cm, minimum height=1cm,text centered, draw=black]
\tikzstyle{filter} = [rectangle, minimum width=2cm, minimum height=1cm, text centered, text width=2cm, draw=black]
\tikzstyle{dataset} = [chamfered rectangle, chamfered rectangle xsep=4cm, draw=black, text centered]
\tikzstyle{decision} = [diamond, draw=black, text centered, minimum width=1.5cm]
\tikzstyle{arrow} = [thick,->,>=stealth]
\begin{document}
\centering
\begin{tikzpicture}[node distance=2cm, auto]
% NODES cylinder
\node (data1) [data, align=center] {Wang et al 2011 \\ \SI{403} sites \\ \SI{170} proteins};
\node (data2) [data, right of=data1, xshift=2cm, align=center] {Jochmann et al 2014 \\ \SI{1181} sites \\ \SI{540} proteins};
\coordinate (Middle) at ($(data1)!0.5!(data2)$);
\node (filter) [filter, below of=Middle] {Filter redundant sites};
\node (decision1) [decision, below left of=filter, xshift=-.5cm, yshift=-.5cm] {in Sifts};
\node (mss) [dataset, right of=decision1, xshift=1.5cm, align=center] {MSS\\ \SI{1422} sites \\ \SI{640} proteins};
\node (uss) [dataset, right of=mss, align=center, xshift=1.5cm] {USS\\ \SI{98388} sites \\ \SI{640} proteins };
\node (gs) [dataset, below of=uss, align=center] {GS\\ \SI{1164} sites \\ \SI{1164} proteins };
\node (decision2) [decision, below left of=decision1, xshift=-2.5cm] {in Blast};
% \node (discard) [filter, left of=decision2, xshift=-1cm] {Discard};
\coordinate (Middle2) at ($(decision1)!0.5!(decision2)$);
\node (ss143) [dataset, below of=Middle2, align=center, xshift=0cm] {ss143 \\ \SI{143} sites \\ \SI{106} proteins};
\node (decision3) [decision, below of=ss143, align=center, yshift=-.5cm] {Complete \\ backbone};
\node (ss131) [dataset, below of=decision3, align=center, yshift=-.5cm] {SS131\\ \SI{131} sites \\ \SI{0} proteins};
\draw [arrow] (data1) -| (filter);
\draw [arrow] (data2) -| (filter);
\draw [arrow] (filter) -| (mss);
\draw [arrow] (filter) -| (uss);
\draw [arrow] (filter) -| (decision1);
\draw [arrow] (decision1.south) |- node {yes} (ss143.east) ;
\draw [arrow] (decision1) -| node[anchor=south] {no} (decision2) ;
\draw [arrow] (decision2.south) |- node[anchor=north] {yes} (ss143.west) ;
% \draw [arrow] (decision2) -- node[anchor=south] {no} (discard) ;
\draw [arrow] (ss143) -- (decision3) ;
\draw [arrow] (decision3) -- node {yes} (ss131) ;
% \draw [arrow] (decision3) -| node {no} (discard) ;
\node (legend) at (6.5, -10.9){
\begin{tabular}{| m{.15 \textwidth} | m{.15 \textwidth} |}
\hline
\emph{Legend} & \emph{Symbol} \\
\hline
Data &
\begin{tikzpicture}[baseline=0]
\draw[rounded corners] rectangle (1 , 0.45) ;
\addvmargin{1mm}
\end{tikzpicture} \\ \hline
Process &
\begin{tikzpicture}[baseline=0]
\draw rectangle (1 ,0.45) ;
\addvmargin{1mm}
\end{tikzpicture} \\ \hline
Dataset &
\begin{tikzpicture}[baseline=0]
\node [dataset] { \hspace{1cm} } ;
\addvmargin{1mm}
\end{tikzpicture} \\ \hline
Decision &
\begin{tikzpicture}[baseline=0]
\node [decision] {} ;
\addvmargin{1mm}
\end{tikzpicture} \\ \hline
\end{tabular}
};
\end{tikzpicture}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment