Skip to content


Subversion checkout URL

You can clone with
Download ZIP
TikZ library for drawing Bayesian networks, graphical models and (directed) factor graphs in LaTeX.
Branch: master



TikZ library for drawing Bayesian networks, graphical models and (directed) factor graphs in LaTeX.


Provides the following node styles:

  • latent
  • obs
  • det
  • const
  • factor
  • plate
  • gate

Provides the following commands (note that any of the arguments can be empty):

  • \factor [options] {name} {caption} {inputs} {outputs}
  • \plate [options] {name} {fitlist} {caption}
  • \gate [options] {name} {fitlist} {inputs}
  • \vgate {name} {fitlist-left} {caption-left} {fitlist-right} {caption-right} {inputs}
  • \hgate {name} {fitlist-top} {caption-top} {fitlist-bottom} {caption-bottom} {inputs}
  • \edge [options] {inputs} {outputs}
  • \factoredge [options] {inputs} {factors} {outputs}


Install the package by copying tikzlibrarybayesnet.code.tex to your LaTeX system or copy the file into projects that are using it. To use the library in your LaTeX file


Compile the LaTeX example:

pdflatex example.tex

and see the resulting PDF file example.pdf.


Bayesian network.

PCA model as a Bayesian network and a directed factor graph.

Citation influence model

Directed factor graph of the citation influence model.

Related projects

This library is derived from a technical report "Directed Factor Graph Notation for Generative Models" and the accompanying TikZ macros by Laura Dietz 2010 (

GraphViz ( is a more general open source graph visualization software. It uses DOT file format to describe the structure of the graph. The DOT file can be converted to LaTeX using dot2tex (

UAI ( is a simple text file format to describe Markov networks. The UAI file format can be converted to DOT file format using uai2dot (


Copyright (C) 2010-2011 Laura Dietz
Copyright (C) 2012 Jaakko Luttinen

This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version. The license is in the file LICENSE_LPPL and the latest version of this license is in and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later.

This work is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This work is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. See the license in the file LICENSE_GPL or visit <>.

Something went wrong with that request. Please try again.