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?
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.
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).
On OSX & iTerm2, you can do the following (assuming imgcat is installed)
dot abac.dot -Tpng | imgcat
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With