Annotate DOT graphs with images

Shnippoo picture Shnippoo · Oct 17, 2011 · Viewed 7k times · Source

I'm using PyDot to generate Graphviz/dot graphs in python. I would like to annotate my nodes and edges with images read from files, I've found in the documentation how to put an image as a node, but not how to put an image under a node or even less an edge.

http://www.graphviz.org/doc/info/attrs.html

http://www.graphviz.org/doc/info/shapes.html

http://www.graphviz.org/Documentation/html/shapehowto.html

Does anybody know how to do that?

Answer

Brad picture Brad · Mar 4, 2012

You can use HTML in the labels for nodes and edges. You can find details here: http://www.graphviz.org/doc/info/shapes.html#html

Basically you can say something

"a" -> "b" [label = <<TABLE><TR><TD><IMG SRC="path/to/picture"/></TD></TR></Table>>]

You can add as many rows and columns as you want in the html labels. It's a little more verbose than standard text labels, but you can do a bit more with them.