0.1 Appendix III. The Plotting of Lab Data with GNU plotutils

This suite of graphics utilities can be used to build publication quality graphs from raw data. It consists of the command-line programs graph, plot, spline, ode and several others. The use of graph is the subject of this section.
Graph can output is work into a variety of formats and devices, chosen with the command-line option -T. For example

graph -T X data

will output the resulting figure into xplot, an X windows primitive graphing canvas. To output to pnm, xfig, Postscript, or GIF, one just passes this choice to graph at invocation and redirects the resulting data into a file, for example

graph -T ps data > data.ps

Read through the voluminous /usr/local/info/plotutils.info file for more command line options, such as those needed to limit the abcissa and ordinates xmin x xmax, ymin y ymax

graph -T ps -x xmin xmax -y ymin ymax data > data.ps

or plotting several data files on the same figure

graph -T ps data1 data2 data3  > data.ps

or perhaps using a logarithmic x-axis within domain 100 x 104

graph -T ps -l x -x 0 4 data > data.ps

One can add labels to the x and y axes as well as a banner label

graph -T ps -X ‘‘ x, m’’ -Y ‘‘Volts’’ -L ‘‘Voltage per meter’’ data > data.ps

The labels can have Greek letters or math symbols, which are given later in a table in this document

graph -T ps -L ‘‘ \*Q\sp*\ep(x,t)\*Q(x,t) for t=0.1 s’’ data > data.ps

will print “Ψ*(x,t)Ψ(x,t)fort = 0.1s” along the top of the figure.
Graph has the capacity to produce graphs within graphs, or to make multigraphs consisting of many repositioned plots. For example the command

graph -T ps --reposition 0.0 0.6 0.3 -L "a=0.07" 07 --reposition 0.3 0.6 0.3  
-L "a=0.09" 09 --reposition 0.6 0.6 0.3 -L "a=0.11" 11 --reposition 0.0 0.3  
0.3 -L "a=0.13" 13  --reposition 0.3 0.3 0.3  -L "a=0.15" 15  --reposition 0.6  
0.3 0.3 -L "a=0.17" 17 --reposition 0.0 0.0 0.3 -L "a=0.19" 19 --reposition  
0.3 0.0 0.3 -L "a=0.21" 21  --reposition 0.6 0.0 0.3 -L "a=0.23" 23 >page1.ps

will create the following multiplot

PIC

The fact that these programs are command-line means that they can be used in shell-scripts or batch files to perform bulk processing of graphics files.
For plotting discrete data points the switch -S allows you to use a large variety of symbols for individual data points



Symbol numberSymbol


1
2 +
3 *
4
5 ×


with 31 different symbols in all. For example

graph -T ps -S 4 0.01 data > data.ps

uses circles whose size is 0.01 times the size of the box within which the entire plot is drawn.
Plots can be rotated by 90, 180, 270 degrees with –rotation

graph -T ps --rotation 90 > data.ps

Lines connecting data points in plots can be manipulated with -m, line mode 0 is no connecting line. Line style, width, and even color can be manipulated. For example we use -m to change linemode from solid to dotted or dashed, but adding -C changes this to color linemode rather than breaking the line in different ways. We can place a plot within a plot by repositioning the second plot within the first and shrinking it;

graph -T ps -C -m 2 data1 --reposition 0.5 0.5 0.3 data2>data.ps

results in

PIC

or we can try

graph -T ps -C -m 3 data1 --reposition 0.5 0.5 0.1 data2>data.ps

which produces

PIC

The –reposition is relative to the point (0.0, 0.0) being the lower left corner of the physical display, and (1.0, 1.0) being the upper right corner. In the first example a miniature virtual display of size 0.3 will be place with its lower left corner at (0.5, 0.5).

These few examples are enough to get started with in using graph, and you really should read through the info file to learn more since this barely scratches the surface.
One of the most useful features of libplot is the generous collection of font symbols that it recognizes for drawing strings on plots. These include Greek letters and mathematical symbols. For example

graph -T X -L "P\sb2\eb(cos\*h)"

will result in the string P2(cos θ) being drawn on the plot title or label. A partial table of useable symbols is given below

|symbol-|escape--seq.||symbol--|escape-seq.||symbol--|escape-seq.||symbol--|escape-seq.-|
|-------|------------||--------|-----------||--------|-----------||--------|------------|
|α------|\-*-a-------||β-------|\ *-b------||Γ-------|\ *-G------||χ-------|\ *-x-------|
|Δ------|\-*-D-------||ε-------|\ *-e------||Φ-------|\ *-F------||Λ-------|\ *-L-------|
|μ      |\ * m       ||ν       |\ * n      ||η       |\ * y      ||Π       |\ * P       |
|Θ------|\-*-H-------||ρ-------|\ *-R------||Σ-------|\ *-S------||τ-------|\ *-t-------|
|-------|------------||--------|-----------||--------|-----------||--------|------------|
|Υ------|\-*-U-------||Ω-------|\ *-W------||Ξ-------|\ *-C------||Ψ-------|\ *-Q-------|
|ζ------|\-*-z-------||δ-------|\ *-d------||γ-------|\ *-g------||σ-------|\ *-s-------|
|θ      |\ * h       ||π       |\ * p      ||φ       |\ * f      ||λ       |\ * l       |
|ψ------|\-*-q-------||∞-------|\if---------||←-------|\ <--------||→-------|\-->--------|
|-------|------------||--------|-----------||--------|-----------||--------|------------|
|±------|\-+---------||∝-------|\pt--------||∂∑-------|\pd--------||∩∫-------|\ca---------|
|∪∮------|\cu---------||∇-------|\gr--------||--------|\SU--------||--------|\is---------|
---------\li-----------ˉh--------\hb----------†--------\dg----------℘--------\wp---------|
|∅      |\es         ||⊕       |\c+        ||⊗       |\c*        ||ℵ       |\Ah         |
|-------|------------||--------|-----------||--------|-----------||√-------|------------|
|⁄=------|\!-=----------≥--------\ >=---------≤--------\ <=------------------\sr---------|
|       |

Some of these symbols are only available if pl_fontname has been used to set the font to Hershey or HersheySans. Subscripts and superscripts can be created using the delimiters illustrated by the following example;

graph -T X -X"\*Q\sp*\ep\\sbn,l,m\eb(r,\*f,\\*h)"

writes Ψn,l,m*(r,φ,θ) to the x-axis label,

graph -T ps -L" L\sp\*a\ep\sb n\eb(r)" > out.ps

writes Lnα(r) to the label. This PostScript output is being redirected to a file.