Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save berndweiss/d11731b6f0cfe75623169c9ad0b6bfed to your computer and use it in GitHub Desktop.
Save berndweiss/d11731b6f0cfe75623169c9ad0b6bfed to your computer and use it in GitHub Desktop.
TikZ-based LaTeX code to create 3 basic DAGs in epidemiology/biostatistics.
\documentclass[]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
%Graph 1
\begin{figure}
\caption{Graph 1}
\large{\begin{tikzpicture}[%
->,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {Y};
\node[left=of 1] (2) {A};
\node[right=of 1] (3) {L};
\draw [->] (1.east) -- (3.west);
\draw [->] (2) to [out=30, in=150] (3);
\end{tikzpicture}}
\end{figure}
%Graph 2
\begin{figure}
\caption{Graph 2}
\large{\begin{tikzpicture}[%
->,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {L};
\node[left=of 1] (2) {A};
\node[below left=of 2] (3) {U};
\node[right=of 1] (4) {Y};
\draw [->] (2) to (1);
\draw [->] (3) to (1);
\draw [->] (3) to (4);
\end{tikzpicture}}
\end{figure}
%Graph 3
\begin{figure}
\caption{Graph 3}
\large{\begin{tikzpicture}[%
->,
>=stealth,
node distance=1cm,
pil/.style={
->,
thick,
shorten =2pt,}
]
\node (1) {Y};
\node[left=of 1] (2) {A};
\node[right=of 1] (3) {L};
\node[rectangle, draw, right=of 3] (4) {C};
\draw [->] (1) to (3);
\draw [->] (3) to (4);
\draw [->] (2) to [out=30, in=150] (3);
\end{tikzpicture}}
\end{figure}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment