Example jgraph scripts

The unix utility jgraph is the best available tool for massaging data
into two-dimensional graphs.
The scripts describe the graphs at a fairly low level, however, and
some experience is required to get the output you want.
In this page, I've collected some jgraph scripts I've written
for different purposes.

Two lines (curves) can be distinguished using linetype
but sometimes lines that are dashed (dotted, whatever) just
look tacky.
In this curve, I've used linethickness and gray.
Remember that gray 0 is black and gray 1 is white.

The points to be plotted can be included directly in the script,
but in this case I have used the shell command facility to all
awk to suck them in from files.
For this graph, either method would do
(see this source for the
same curves without awk), but in general use of shell commands
makes scripting much easier.
For example, several curves can be plotted from the one data
file, by using awk to pull out different columns.

I haven't used the facility for placing a label under the graph.
For tex/latex, labels are provided by the \caption command.

Error bars

Bar graphs

Another useful form of graph is a
bar graph
(source).
As this example shows, generating the bars is slightly
tricky: for each bar, it is necessary to choose width and
placement.
However, the bars follow a simple, regular pattern, so this
is easy to do with a script.

Yet another variant of this graph is to use
long labels
(source)
that have to be rotated to fit.
These can be done, with some difficult, with newstring.
The rotation is anti-clockwise, about the centre of the string.
Thus, since the intention is to place the right-hand end of the string
at a particular point, the location of the middle of each string has
to be found individually.
(It is not clear why this was done this way, when the vjr
directive could have been used.)

A more principled way of doing this is with the generic
hash_labels formatting directive, as in this version
of the above bargraph
(source).

to add a faint horizontal line at height 50 on a graph with domain [0,100].
While it is tiresome to add a newcurve instruction for every gridline,
it is straightforward to generate them with an awk script.