I have a print_dot()
function that outputs dot on stdout.
That way I can do:
$ ./myprogram < input | dot -T x11
It works great when I try to print one graph.
Now when I print several graphs, nothing shows up. The dot window is blank, X11 and dot take all the CPU. Nothing is printed on stderr.
$ echo -e "graph { a -- b }" | dot -T x11 # work
$ echo -e "graph { a -- b } \n graph { c --d }" | dot -T x11 # doesn't work
# it seems to be interpreted nonetheless
$ echo -e "graph { a -- b } \n graph { c -- d } " | dot -T xdot
graph {
...
}
graph {
...
}
Also, when I remove the \n
between the 2 graphs, only the first graph is interpreted (what a nice feature...):
$ echo -e "graph { a -- b } graph { c -- d } " | dot -T xdot
graph {
...
}
Piping the xdot output to dot again doesn't fix the problem.
So, how does one render multiple graphs with graphviz?
Similar to undirected graphs, DOT can describe directed graphs, such as flowcharts and dependency trees. The syntax is the same as for undirected graphs, except the digraph keyword is used to begin the graph, and an arrow (->) is used to show relationships between nodes. digraph graphname { a -> b -> c; b -> d; }
The basis of a dot plot is data points plotted as dots on a graph with an x- and y-axis. Dot plots are generally arranged with one axis showing the range of values or categories along which the data points are grouped and a second axis showing the number of data points in each group.
A dot plot, also called a dot chart, is a type of simple histogram-like chart used in statistics for relatively small data sets where values fall into a number of discrete bins. To draw a dot plot, count the number of data points falling in each bin and draw a stack of dots that number high for each bin.
One calls dot
multiple times. Or one puts everything into a single graph, taking care to avoid duplication of names.
Use gvpack
$ echo -e "graph { a -- b }\ngraph { c -- d }" | gvpack -u | dot -Tpng > graphs.png
Result
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