Introducing dot2tex - A Graphviz to LaTeX converter
- Published 2006-09-11 (1 year, 8 months ago)
Dot2tex is a tool for converting graphs generated by Graphviz to formats suitable for use with LaTeX. Currently dot2tex generates code for PSTricks and PGF/TikZ. The purpose of dot2tex is to give graphs a more LaTeX look and feel. This is accomplished by:
- Typesetting labels with LaTeX, allowing mathematical notation.
- Use native PSTricks and PGF/TikZ commands for drawing arrows.
Take the following graph in the Dot format as an example:
digraph G {
node [shape=circle];
a_1-> a_2 -> a_3 -> a_1;
}
Rendered with dot -Tps the result will look like the graph
to the left below. Rendered with:
$ dot2tex -tmath example.dot > example.tex
the graph will look like the one to the right.
Dot2tex is available for download under an MIT license. For details about how to use dot2tex, see the documentation.
Motivation
Graphviz is a superb tool for automatic routing and rendering of graphs. It can output rendered graphs in a multitude of formats, including PS, which is practical for inclusion in LaTeX documents. However, for consistency between text and graphics it is desirable to use LaTeX to typeset labels.
Thanks to Graphviz' xdot format it is possible to retrieve the detailed layout and rendering information. Add some Python magic, the pydot module, and it is quite easy to convert the rendering information to a series of PSTricks or PGF/TikZ commands. Now LaTeX can be used to do all of the typesetting and the graph will blend perfectly with the rest of your document.
Dot2tex started as a simple experiment. I had fun writing it. It's still in a early stage of development., but hopefully someone will find it useful. Feedback is appreciated.
Examples
A few examples of dot2tex' features are shown below. Click on the images to download a PDF version.




Comments
Is it possible to use latex to markup edges?
Thank you,
Jonathan
Yes. You can use LaTeX markup in edge labels. See for instance the poltab example in the gallery.
Post a comment
Markdown syntax enabled