Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw multiple graphs with dot?

Tags:

graphviz

dot

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?

like image 994
knarf Avatar asked Mar 17 '11 17:03

knarf


People also ask

What is DOT in flowchart?

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; }

What does a dot plot graph look like?

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.

What is a dot plot in math?

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.


2 Answers

One calls dot multiple times. Or one puts everything into a single graph, taking care to avoid duplication of names.

like image 181
Gareth McCaughan Avatar answered Oct 05 '22 21:10

Gareth McCaughan


Use gvpack

$ echo -e "graph { a -- b }\ngraph { c -- d }" | gvpack -u | dot -Tpng > graphs.png

Result

enter image description here

like image 27
Panic Avatar answered Oct 05 '22 21:10

Panic