![]() | |||||
Introduction
|
1: Introduction
1.1: What `
` |
0.05 12.5 0.25 19 0.5 15 0.75 15 0.95 13 |
This is a datafile. Each line has an `(x,y)
' pair. If you don't
know what an `(x,y)
' pair is, `gre
' may not be what you need for
your work!
open example1.dat; read columns x=1 y=2; draw curve; |
This is a `gre
' program with three commands. Commands are separated
by semicolons; in this case they are also separated by line separators,
but these are optional, as is all whitespace in a `gre
' program. The
commands do the following things.
x
' data from the first column and
`y
' data from the second column.
(x,y)
' points provided in the data-file. The curve comprises
connected line segments -- it is not smoothed, although the word
``curve'' might fool you that it is!
Before the curve is drawn, axes will also be drawn (see below).
gre
' by typing
gre example1 |
to the operating system. `Gre
' assumes the commandfile has suffix
`.gre', so there is no need to supply the suffix, although nothing
is lost if you do supply it.
The three-line program makes use of many default `gre
' actions,
e.g. automatic drawing of axes and automatic selection of scales. All
defaults may be overridden. The following example illustrates how to
get `gre
' to call the y-axis `foo
' instead of `y
', and to
make this axis range from `0
' to `20
', labelled at intervals
of `10
', instead of `12
' to `19
' labelled at unit
intervals (the x-axis still being selected automatically by `gre
'):
open example1.dat; read columns x=1 y=2; set y name "foo"; set y axis 0 20 10; draw curve; |
For more on `set y axis
', see Set y axis.
A note on execution order. Notice that these axis-control
commands were placed before the `draw curve
' command. This
illustrates an important point: `gre
' executes the commands in a
command-file sequentially, starting at the top. If, for example, the
commands for controlling the y-axis were placed after the
`draw curve
' command, they would have no effect on this
graph.
Note for Matlab users: The `gre
' convention of executing
commands in sequence agrees with most programming languages
except Matlab. In matlab, some commands work non-sequentially,
e.g. an `axis
' command can change an existing graph. However,
other Matlab commands (basically, all non-drawing commands) act
sequentially ... imagine how confusing it would be if arithmetic
commands acted out of sequence, as some Matlab graphics commands do!
(c) 1997-2000 Dan E. Kelley, email Dan.Kelley@Dal.Ca