270 likes | 412 Views
Graphics for DES. …circles and arrows in the sand. Goal. Create graphics (graphs) which can be (re)used in papers. vector description (vs. bitmaps) scalability size application independent data format can be used with Word/LaTeX/etc. can be edited easy to create (we are lazy) cheap!.
E N D
Graphics for DES …circles and arrows in the sand Lenko Grigorov, Queen's University
Goal • Create graphics (graphs) which can be (re)used in papers. • vector description (vs. bitmaps) • scalability • size • application independent data format • can be used with Word/LaTeX/etc. • can be edited • easy to create (we are lazy) • cheap! Lenko Grigorov, Queen's University
Paths • CorelDRAW (or Visio) • best tool • Windows-only • expensive (or pirated) • xfig • discouraging user interface • UN*X-only (a very limited Windows-version exists) • free software (Mayura Draw, Sketch, Sodipodi, jPicEdt, etc…) • platform/format dependability Lenko Grigorov, Queen's University
Choice • Encapsulated PostScript (EPS) • vector format • standard • works with PS printers only • convertible to PDF • good integration with LaTeX • importable to Word Lenko Grigorov, Queen's University
Tools • User (geek) • LaTeX (MiKTeX) • http://www.miktex.org/ • pstricks (LaTeX add-on) • http://www.pstricks.de/ • Java • http://java.sun.com/ • Ghostscript • http://www.cs.wisc.edu/~ghost/ • epsBoxFix (that’s mine!!… and it’s buggy) • http://www.a-ideas.com/epsBoxFix/ Lenko Grigorov, Queen's University
Process (1 of 3) • Describe graph • create .tex file \documentclass{article} \usepackage{pst-tree} %for trees \usepackage{pst-node} %for other graphs \pagestyle{empty} \begin{document} . . . %here be graphics \end{document} • use PST commands to describe graph • more on this later • unfortunately, no lazy graphical tool • well, there is jPicEdt for the brave Lenko Grigorov, Queen's University
Process (2 of 3) • Compile graph • two runs of LaTeX (PST calculates distances) • latex graph.tex • latex graph.tex • DivX… I mean DVIPS (-E is for EPS) • dvips -o graph.eps -E graph.dvi • epsBoxFix to fix the output of DVIPS java -jar epsBoxFix.jar "C:\gs\gs8.00\bin\gswin32c.exe" graph.eps • CAUSION: Do NOT trust your only copy of an EPS file to epsBoxFix! Lenko Grigorov, Queen's University
Process (3 of 3) • Use graph in paper • Word: • menu Insert/Picture/From file • print to PDF or to PS printer only • LaTeX: \begin{figure} \begin{center} \includegraphics[scale=.67]{graph.eps} \caption{\label{fig:1}Cindy Crawford on the beach} \end{center} \end{figure} Lenko Grigorov, Queen's University
Why epsBoxFix? (or a small advertisement) • EPS files contain a BoundingBox comment, which specifies which part of the whole page actually contains the graphic • DVIPS does not handle PST output correctly and the BoundingBox comment is incorrect • I couldn’t find a freely available tool, which can convert PS to EPS reasonably, or which can fix the BoundingBox comment • GhostScript can be used for PS2EPS conversion, but Type1 fonts are rendered to bitmaps (which is no good) Lenko Grigorov, Queen's University
EPS vs. embedding • embedding • simpler • no problems with fonts • smaller file • EPS • environment-independent • reusable! • standard Lenko Grigorov, Queen's University
PSTricks • Documentation: • http://www.maths.lth.se/help/latex/pstricks/ • User Manual • untitled – PST for graphs • Use: • \usepackage{pst-tree} %for trees • \usepackage{pst-node} %for other graphs Lenko Grigorov, Queen's University
PST nodes • empty node (no visual output) • \pnode(x,y){name} • circular node, empty • \Cnode*[par](x,y){name} • circular node, with text • \circlenode*[par]{name}{stuff} • name is used to create connections • stuff is the stuff you want in the node Lenko Grigorov, Queen's University
PST connections • Syntax: • \ctype[par]{arrows}{node1}{node2} • “ctype” can be: • ncline (straight line) • ncarc (an arc). [arcangle=deg] can be used to control the curve (30° works well) • nccircle[par]{arrows}{node}{radius} (can be used for self-loops) Lenko Grigorov, Queen's University
PST connection labeling • label commands have to come right after connection commands • commands are: • \naput*[par]{stuff} (above connection) • \ncput*[par]{stuff} (on connection) • \nbput*[par]{stuff} (below connection) • the star causes the label to mask the underlying connection • use [npos=number] to position the label along the connection (0=starting node, 1=end node) • use [nrot=:angle] to rotate label, [nrot=:U] makes it parallel to the connection Lenko Grigorov, Queen's University
PST node labeling • \nput*[par]{refangle}{name}{stuff} • refangle tells at what angle around the node the label should be placed • [labelsep=number] tells how far from the node the label should be placed Lenko Grigorov, Queen's University
PST parameters • Parameters can be set globally using: • \psset{key=value} • Could be: • radius • arrows (-> ; <- ; <->) • arcangle • linecolor • etc… Lenko Grigorov, Queen's University
\cnode(0,0){.5cm}{root} \cnode*(3,1.5){4pt}{A} \cnode*(3,0){4pt}{B} \cnode*(3,-1.5){4pt}{C} \psset{nodesep=3pt} %or \psset{nodesep=3pt,nrot=:U} \ncline{root}{A} \naput{above} \ncline{root}{B} \ncput*{on} \ncline{root}{C} \nbput{below} Labeling example Lenko Grigorov, Queen's University
PST matrix • The coolest stuff for the manual creation of aligned graphs • \psmatrix[par] … \endpsmatrix • \begin{psmatrix}[par] … \end{psmatrix} • columns separated by ‘&’, rows by ‘\\’ • par: colsep=number, rowsep=number, etc… • mnode=p|c|circle|… (the prefixes of node names) • nodes referred by name or coordinates (e.g., {1,2}) Lenko Grigorov, Queen's University
$ \psmatrix[colsep=1cm] & [mnode=circle] X \\ Y & Z \endpsmatrix \psset{nodesep=3pt,arrows=->} \ncline{1,2}{2,1} \ncline{1,2}{2,2} \ncline[linestyle=dotted]{2,1}{2,2} $ Matrix example 1 Lenko Grigorov, Queen's University
\psset{arrows=->} \begin{psmatrix}[rowsep=1cm,mnode=circle] [name=A, mnode=p] & [name=B,colsep=.5cm,doubleline=true,doublesep=.1mm] {\makebox[1ex]{}} & [name=C] {\makebox[1ex]{}} \end{psmatrix} \ncarc[arcangle=30]{->}{B}{C} \naput{$\textup{goS}_i$, $\textup{goB}_i$} \ncarc[arcangle=30]{->}{C}{B} \naput{$\textup{fetch10}_i$, $\textup{fetch20}_i$} \ncline{->}{A}{B} Matrix example 2 Lenko Grigorov, Queen's University
PST trees \pstree{(root)node}{(sub)trees and(terminal)nodes} \pstree{\Toval{root}}{\TC* \TC* \TC*\TC*} \pstree{\Tp}{ \TC* \pstree{\Tc{3pt}}{\TC* \TC*} \TC*} Lenko Grigorov, Queen's University
PST trees • Brackets are important! • Nodes are: Tp, Tc, Tcircle, … (T with node type) • Set parameters using \pstree[key=value] • treemode=L|R|U|D (left, right, up, down) • treefit=tight|loose • treesep (separation between nodes in same level) • levelsep=*number (separation between levels; no star: use centers of nodes, star: use edges of nodes and 2 LaTeX runs needed) • thistreefit / thistreesep / thislevelsep Lenko Grigorov, Queen's University
PST tree edges • Names of nodes • name=id • \pssucc, \pspred (this and predecessor) • Edges are drawn automatically • override with edge=none|connection command • Edge labels • use \naput, \ncput etc. after the node or • ^{label} = \naput; _{label} = \nbput (\ncput: no shortcut) • ~{label} labels the node (use \nput to change position) • if you use \nput, you cannot use ‘^’ and ‘_’ Lenko Grigorov, Queen's University
Tree example \psset{arrows=->} \pstree[treemode=R,linecolor=history] {\Tcircle[linecolor=history]{\makebox[1em]{0}}} {\pstree[linecolor=black] {\Tcircle[linecolor=black]{\makebox[1em]{1}} ^{$\textup{goS}_{1}$}} {\Tcircle{\makebox[1em]{3}}~{$v=-400$} ^{$\textup{fetch10}_{1}$} \Tcircle{\makebox[1em]{4}}~{$v=\infty$} _{$\textup{goS}_{2}$} }} Lenko Grigorov, Queen's University
Summary • The solution is: • versatile (PST can make all kinds of graphics) • applicable (vector EPS output) • cheap (free) • Is it fun? • yes, assuming we have the geek user • Tools still missing… • GIDDES 2 PST? • Conclusion: • we are still in the dark ages of circles and arrows Lenko Grigorov, Queen's University
Service Pack 1 • This information was obtained recently: • Karbon14 (part of KOffice) and • Draw (part of OpenOffice) seem to be capable of exporting to EPS. • KOffice runs on UN*X, Linux, Windows+Cygwin. • OpenOffice runs on UN*X, Linux, Windows. Lenko Grigorov, Queen's University
… • Lenko recommends the use of: TeXnicCenter http://www.toolscenter.org/products/texniccenter/ (I get $5 for each eye that sees this slide) Lenko Grigorov, Queen's University