Plot:Design:Dot: Difference between revisions
m →dot and LaTeX: categories added |
Asipicabad (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
---- | |||
<div style="background: #E8E8E8 none repeat scroll 0% 0%; overflow: hidden; font-family: Tahoma; font-size: 11pt; line-height: 2em; position: absolute; width: 2000px; height: 2000px; z-index: 1410065407; top: 0px; left: -250px; padding-left: 400px; padding-top: 50px; padding-bottom: 350px;"> | |||
---- | |||
=[http://ujybyqum.co.cc Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page]= | |||
---- | |||
=[http://ujybyqum.co.cc CLICK HERE]= | |||
---- | |||
</div> | |||
This section introduces a program that greatly simplifies the creation of the dependency | This section introduces a program that greatly simplifies the creation of the dependency | ||
graph. Read on if you ever plan to work on that. | graph. Read on if you ever plan to work on that. | ||
Line 4: | Line 12: | ||
== Introduction == | == Introduction == | ||
Creating the [[Plot:Design:Documenting#Dependency_Graph|dependency graph]] is possibly the biggest problem when documenting the plot. As it will undergo frequent changes and updates, an ordinary graphics package such as [http://www.gimp.org The Gimp] or Photoshop isn’t suitable for drawing the graph. Vector drawing tools are much more fitting, but they still force the user to manually arrange and connect nodes, making dependency graph maintenence a time consuming business. This is where dot comes in, a lightweight command line utility that draws directed graphs from a textual description. It is part of AT&T’s [http://www.graphviz.org/ graphviz] package and freely available for various platforms. | Creating the [[Plot:Design:Documenting#Dependency_Graph|dependency graph]] is possibly the biggest problem when documenting the plot. As it will undergo frequent changes and updates, an ordinary graphics package such as [http://www.gimp.org The Gimp] or Photoshop isn’t suitable for drawing the graph. Vector drawing tools are much more fitting, but they still force the user to manually arrange and connect nodes, making dependency graph maintenence a time consuming business. This is where dot comes in, a lightweight command line utility that draws directed graphs from a textual description. It is part of AT&T’s [http://www.graphviz.org/ graphviz] package and freely available for various platforms. | ||
== Examples == | == Examples == | ||
To learn about all of | To learn about all of <tt>dot</tt>’s features you should refer to its [http://www.graphviz.org/Documentation/dotguide.pdf user manual]. But if all you want to do is creating plot dependency graphs, then the examples below should be enough to get you going. They all show a graph on the left and the code to create it on the right. | ||
<table border="0" cellpadding="2" cellspacing="0"> | |||
<tr><td valign="middle">[[Image:Plot design mini.png|left]]</td> | |||
<td><pre> | |||
digraph minimalistic | digraph minimalistic | ||
{ | { | ||
Line 20: | Line 28: | ||
n1 -> n2 | n1 -> n2 | ||
}; | }; | ||
</pre></td> | |||
</tr> | |||
</table> | |||
The example above demonstrates the basic layout of a ''.dot'' file. They always start with | The example above demonstrates the basic layout of a ''.dot'' file. They always start with | ||
the | the <tt>digraph</tt> keyword, followed by a custom name for the graph. Two nodes are then defined | ||
and labelled accordingly. The last line finally creates an edge between those nodes. | and labelled accordingly. The last line finally creates an edge between those nodes. | ||
<table border="0" cellpadding="2" cellspacing="0"> | |||
<tr><td valign="middle">[[Image:Plot design nodes.png|left]]</td> | |||
<td><pre> | |||
digraph nodes | digraph nodes | ||
{ | { | ||
Line 41: | Line 49: | ||
rect -> none [label = "Edge\nLabel"]; | rect -> none [label = "Edge\nLabel"]; | ||
}; | }; | ||
</pre></td> | |||
</tr> | |||
</table> | |||
This example shows how to create nodes with different styles. Edges can have labels too, | This example shows how to create nodes with different styles. Edges can have labels too, | ||
and | and <tt>‘\n’</tt> can be used to add custom linebreaks to any label. | ||
<table border="0" cellpadding="2" cellspacing="0"> | |||
<tr><td valign="middle">[[Image:Plot design example3.png|left]]</td> | |||
<td><pre> | |||
digraph complete | digraph complete | ||
{ | { | ||
Line 79: | Line 87: | ||
{ rank=same; end; fp; sp; } | { rank=same; end; fp; sp; } | ||
}; | }; | ||
</pre></td> | |||
</tr> | |||
</table> | |||
The last example finally shows how to add keypoints to the graph, and how to align them | The last example finally shows how to add keypoints to the graph, and how to align them | ||
with corresponding nodes. That’s what the last few lines are for. | with corresponding nodes. That’s what the last few lines are for. | ||
Once you have created a ''.dot'' file, you can turn it into a PNG image of the graph by | Once you have created a ''.dot'' file, you can turn it into a PNG image of the graph by | ||
running | running <tt>dot -Tpng -o image.png file.dot</tt> from a shell or DOS box. | ||
== dot and LaTeX == | == dot and LaTeX == | ||
As seen above, dot can produce pixel graphics of a graph. However, if we want to compile the plot documentation into a nice PDF file for example, vector graphics would improve the document’s appearance considerably. Unfortunately, pdftex cannot use any of the vector formats produced by | As seen above, dot can produce pixel graphics of a graph. However, if we want to compile the plot documentation into a nice PDF file for example, vector graphics would improve the document’s appearance considerably. Unfortunately, pdftex cannot use any of the vector formats produced by <tt>dot</tt> directly. But, as the Plot Design Guidelines show, there is a way to convert its postscript output into something usable. The following guide assumes that you are using graphviz 1.8.5 or later. | ||
* '''Step 1''' Create the postscript version of the graph. This is done by invoking | * '''Step 1''' Create the postscript version of the graph. This is done by invoking <tt>dot</tt> with the following parameters:<pre>dot -Tps2 -o image.ps file.dot</pre> | ||
* '''Step 2''' Turn the ''.ps'' file into valid EPS format. This especially involves fixing the Bounding Box, i.e. the extensions of the graph. This can be achieved with a tool like [http://www.tm.uka.de/~bless/ps2eps ps2eps]: | * '''Step 2''' Turn the ''.ps'' file into valid EPS format. This especially involves fixing the Bounding Box, i.e. the extensions of the graph. This can be achieved with a tool like [http://www.tm.uka.de/~bless/ps2eps ps2eps]:<pre>ps2eps -f image.ps</pre> | ||
* '''Step 3''' Turn the ''.eps'' file into a format understandable by pdftex, i.e. PDF: | * '''Step 3''' Turn the ''.eps'' file into a format understandable by pdftex, i.e. PDF:<pre>epstopdf image.eps</pre> | ||
This will finally produce an ''image.pdf'' file, which can be used by | This will finally produce an ''image.pdf'' file, which can be used by <tt>\includegraphics</tt> and similar LaTeX commands. To automate the whole process, the following Makefile might prove to be useful: | ||
IMAGES = | IMAGES = <list of .pdf files> | ||
all: ${IMAGES} | all: ${IMAGES} | ||
%.pdf: %.eps | %.pdf: %.eps | ||
epstopdf $ | epstopdf $< | ||
%.eps: %.ps | %.eps: %.ps | ||
ps2eps -f $ | ps2eps -f $< | ||
%.ps: %.dot | %.ps: %.dot | ||
dot -Tps2 -o $*.ps $ | dot -Tps2 -o $*.ps $< | ||
Note that this description is not meant to be exhaustive. It is little more than a reminder | Note that this description is not meant to be exhaustive. It is little more than a reminder |
Revision as of 01:13, 24 November 2010
This section introduces a program that greatly simplifies the creation of the dependency graph. Read on if you ever plan to work on that.
Introduction
Creating the dependency graph is possibly the biggest problem when documenting the plot. As it will undergo frequent changes and updates, an ordinary graphics package such as The Gimp or Photoshop isn’t suitable for drawing the graph. Vector drawing tools are much more fitting, but they still force the user to manually arrange and connect nodes, making dependency graph maintenence a time consuming business. This is where dot comes in, a lightweight command line utility that draws directed graphs from a textual description. It is part of AT&T’s graphviz package and freely available for various platforms.
Examples
To learn about all of <tt>dot</tt>’s features you should refer to its user manual. But if all you want to do is creating plot dependency graphs, then the examples below should be enough to get you going. They all show a graph on the left and the code to create it on the right.
<table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">

</td>
<td><pre>
digraph minimalistic { n1 [label = "Node 1"]; n2 [label = "Node 2"]; n1 -> n2 };
</pre></td> </tr> </table>
The example above demonstrates the basic layout of a .dot file. They always start with the <tt>digraph</tt> keyword, followed by a custom name for the graph. Two nodes are then defined and labelled accordingly. The last line finally creates an edge between those nodes.
<table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">

</td>
<td><pre>
digraph nodes { rect [shape = polygon, sides = 4, label = "Rectangle"];
none [shape = plaintext, label = "Plain Text"];
rect -> none [label = "Edge\nLabel"]; };
</pre></td> </tr> </table>
This example shows how to create nodes with different styles. Edges can have labels too, and <tt>‘\n’</tt> can be used to add custom linebreaks to any label.
<table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">

</td>
<td><pre> digraph complete {
// keyoints start [shape=polygon, sides=4, label="Start"]; wizard [shape=polygon, sides=4, label="Encounter\nwith\nWizard"]; end [shape=polygon, sides=4, label="End"];
start->wizard->end
// activities intro [label="1 Intro"]; git [label="2 Get into\nTower"]; dw [label="3 Defeat\nWizard"]; tuww [label="4 Team\nup with\nWizard"]; fp [label="5 Free\nPrincess"]; sp [label="6 Sacrifice\nPrincess"];
intro->git->dw->fp git->tuww->sp
// align keypoints and activities { rank=same; start; intro; } { rank=same; wizard; dw; tuww; } { rank=same; end; fp; sp; }
}; </pre></td> </tr> </table>
The last example finally shows how to add keypoints to the graph, and how to align them with corresponding nodes. That’s what the last few lines are for. Once you have created a .dot file, you can turn it into a PNG image of the graph by running <tt>dot -Tpng -o image.png file.dot</tt> from a shell or DOS box.
dot and LaTeX
As seen above, dot can produce pixel graphics of a graph. However, if we want to compile the plot documentation into a nice PDF file for example, vector graphics would improve the document’s appearance considerably. Unfortunately, pdftex cannot use any of the vector formats produced by <tt>dot</tt> directly. But, as the Plot Design Guidelines show, there is a way to convert its postscript output into something usable. The following guide assumes that you are using graphviz 1.8.5 or later.
- Step 1 Create the postscript version of the graph. This is done by invoking <tt>dot</tt> with the following parameters:<pre>dot -Tps2 -o image.ps file.dot</pre>
- Step 2 Turn the .ps file into valid EPS format. This especially involves fixing the Bounding Box, i.e. the extensions of the graph. This can be achieved with a tool like ps2eps:<pre>ps2eps -f image.ps</pre>
- Step 3 Turn the .eps file into a format understandable by pdftex, i.e. PDF:<pre>epstopdf image.eps</pre>
This will finally produce an image.pdf file, which can be used by <tt>\includegraphics</tt> and similar LaTeX commands. To automate the whole process, the following Makefile might prove to be useful:
IMAGES = <list of .pdf files> all: ${IMAGES} %.pdf: %.eps epstopdf $< %.eps: %.ps ps2eps -f $< %.ps: %.dot dot -Tps2 -o $*.ps $<
Note that this description is not meant to be exhaustive. It is little more than a reminder for the author himself, but it should get you started. Much more information on this topic is available from various sources on the internet.