Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display image from Graphviz without creating an intermediate file?

I would like to display a graph without writing a file first.

Suppose I have a command foo that produces this on standard out:

digraph foogrph {
   a -> b;
   a -> c;
}

What I would like to do is pipe foo into dot and then pipe the results into a command that will display the image in a graphical environment.

foo | dot -Tpng | <display command>

I have found a workaround that involves temporary files. In OSX, I can do the following:

foo | dot -Tpng > temp && open temp

But I still have to remove the file from the filesystem.

How can I display an image that is being written to standard out?

like image 649
tlehman Avatar asked Apr 12 '13 23:04

tlehman


People also ask

What is DOT output?

The dot option corresponds to attributed dot output, and is the default output format. It reproduces the input, along with layout information for the graph. In particular, a bb attribute is attached to the graph, specifying the bounding box of the drawing.


2 Answers

With ImageMagick's display command, these work on Ubuntu 12.10 (and most likely other OSes, too):

dot abac.dot -Tsvg | display
dot abac.dot -Tpng | display

SVG has the advantage of smoothly scaling with the window (if that's what you want).

like image 117
Tom Blodget Avatar answered Oct 23 '22 07:10

Tom Blodget


On OSX & iTerm2, you can do the following (assuming imgcat is installed)

dot abac.dot -Tpng | imgcat

enter image description here

like image 42
jake256 Avatar answered Oct 23 '22 05:10

jake256