Forked from lcomm/Directed Acyclic Graphs in LaTeX using TikZ
Created
May 14, 2016 05:15
-
-
Save berndweiss/d11731b6f0cfe75623169c9ad0b6bfed to your computer and use it in GitHub Desktop.
TikZ-based LaTeX code to create 3 basic DAGs in epidemiology/biostatistics.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\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