我正在使用資料庫,並希望建立流程圖,顯示當我套用每個篩選條件時丟失了多少個案例。簡而言之,我想產生一個「老派」流程圖,如下所示。這關聯展示如何使用 創建彩色圖片\usepackage{smartdiagram}
,但是我想創建一個非常簡單、直截了當的圖表。是否有為此預製的軟體包,或者必須使用 來構建它\usepackage{tikz}
?
答案1
\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}%
[data/.style=
{draw,minimum height=0.7cm,minimum width=2cm,align=center},
filter/.style=
{draw,minimum height=1.3cm,minimum width=3cm,align=center},
database/.style=
{draw,minimum height=1.5cm,minimum width=3cm,align=center},
flow/.style={thick,-stealth},
apply/.style={}
]
\node[database] (db) {Database\\1995--2015};
\node[data,below=of db] (d1) {$N=4\,199$};
\node[data,below=of d1] (d2) {$N=2\,848$};
\node[data,below=of d2] (d3) {$N=2\,561$};
\draw[flow] (db) -- (d1);
\draw[flow] (d1) -- coordinate(d1d2) (d2);
\draw[flow] (d2) -- coordinate(d2d3) (d3);
\node[filter,right=of db] (excl) {Exclusions};
\node[filter] (f1) at (d1d2-|excl) {Males\\($N=250$)};
\draw[apply] (d1d2) -- (f1);
\node[filter] (f2) at (d2d3-|excl) {Not Obese\\($N=250$)};
\draw[apply] (d2d3) -- (f2);
\end{tikzpicture}
\end{document}