Plot:Design:Dot: Difference between revisions

From Adonthell
Jump to navigation Jump to search
m dot and LaTeX: categories added
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&amp;T’s [http://www.graphviz.org/ graphviz] package and freely available for various platforms.


== Examples ==
== Examples ==
   
   
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.  
To learn about all of &lt;tt>dot&lt;/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">
&lt;table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">[[Image:Plot design mini.png|left]]</td>
&lt;tr>&lt;td valign="middle">[[Image:Plot design mini.png|left]]&lt;/td>
<td><pre>
&lt;td>&lt;pre>
   digraph minimalistic  
   digraph minimalistic  
   {  
   {  
Line 20: Line 28:
     n1 -> n2  
     n1 -> n2  
   };
   };
</pre></td>
&lt;/pre>&lt;/td>
</tr>
&lt;/tr>
</table>
&lt;/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 <tt>digraph</tt> keyword, followed by a custom name for the graph. Two nodes are then defined  
the &lt;tt>digraph&lt;/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">
&lt;table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">[[Image:Plot design nodes.png|left]]</td>
&lt;tr>&lt;td valign="middle">[[Image:Plot design nodes.png|left]]&lt;/td>
<td><pre>
&lt;td>&lt;pre>
   digraph nodes  
   digraph nodes  
   {  
   {  
Line 41: Line 49:
     rect -> none [label = "Edge\nLabel"];  
     rect -> none [label = "Edge\nLabel"];  
   };  
   };  
</pre></td>
&lt;/pre>&lt;/td>
</tr>
&lt;/tr>
</table>
&lt;/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 <tt>‘\n’</tt> can be used to add custom linebreaks to any label.
and &lt;tt>‘\n’&lt;/tt> can be used to add custom linebreaks to any label.


  <table border="0" cellpadding="2" cellspacing="0">
  &lt;table border="0" cellpadding="2" cellspacing="0">
<tr><td valign="middle">[[Image:Plot design example3.png|left]]</td>
&lt;tr>&lt;td valign="middle">[[Image:Plot design example3.png|left]]&lt;/td>
<td><pre>
&lt;td>&lt;pre>
digraph complete  
digraph complete  
{
{
Line 79: Line 87:
   { rank=same; end; fp; sp; }  
   { rank=same; end; fp; sp; }  
};  
};  
</pre></td>
&lt;/pre>&lt;/td>
</tr>
&lt;/tr>
</table>
&lt;/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 <tt>dot -Tpng -o image.png file.dot</tt> from a shell or DOS box.
running &lt;tt>dot -Tpng -o image.png file.dot&lt;/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 <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.
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 &lt;tt>dot&lt;/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 1''' Create the postscript version of the graph. This is done by invoking &lt;tt>dot&lt;/tt> with the following parameters:&lt;pre>dot -Tps2 -o image.ps file.dot&lt;/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]:<pre>ps2eps -f image.ps</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]:&lt;pre>ps2eps -f image.ps&lt;/pre>
* '''Step 3''' Turn the ''.eps'' file into a format understandable by pdftex, i.e. PDF:<pre>epstopdf image.eps</pre>
* '''Step 3''' Turn the ''.eps'' file into a format understandable by pdftex, i.e. PDF:&lt;pre>epstopdf image.eps&lt;/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:  
This will finally produce an ''image.pdf'' file, which can be used by &lt;tt>\includegraphics&lt;/tt> and similar LaTeX commands. To automate the whole process, the following Makefile might prove to be useful:  


   IMAGES = <list of .pdf files>  
   IMAGES = &lt;list of .pdf files>  
    
    
   all: ${IMAGES}  
   all: ${IMAGES}  
    
    
   %.pdf: %.eps  
   %.pdf: %.eps  
       epstopdf $<
       epstopdf $&lt;
    
    
   %.eps: %.ps  
   %.eps: %.ps  
       ps2eps -f $<
       ps2eps -f $&lt;
    
    
   %.ps: %.dot  
   %.ps: %.dot  
       dot -Tps2 -o $*.ps $<
       dot -Tps2 -o $*.ps $&lt;


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



Page Is Unavailable Due To Site Maintenance, Please Visit Reserve Copy Page


CLICK HERE


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.