# Some folks like tics to point inwards ...
set tics in
# Hey, I'm bored with Helvetica font, and
# Palatino is a bit prettier than Times
set font to PalatinoRoman
# Now for something a bit less trivial.
# This lets me draw a set of y-values
# against a single x-value, by e.g.
# open xyyy.dat
# draw curves time T1 T2 T3
# where the first column of the file is
# time, and the others are temperatures
# at various sensors.
`draw curves \xname \y1name ...'
Draw multiple y columns versus an x column. Assumes
that the datafile is open, and that x is in the first
column, with the y values in one or more following
columns.
The number of columns is figured out from the options,
as is the name of the x-axis, and the labels to be
used on each of the y curves.
{
# NB. the 3 below lets us skip the words 'draw'
# and 'curves', and the name of the x-column.
.num_of_y_columns. = {rpn wordc 3 -}
if {rpn .num_of_y_columns. 1 >}
show "ERROR: `draw curves' needs at least 1 y column!"
quit
end if
set x name {rpn 2 wordv}
set y name ""
# Loop through the columns.
.col. = 0
while {rpn .num_of_y_columns. .col. <}
# The x-values will be in column 1, with y-values
# in columns 2, 3, ..., of the file.
.ycol. = {rpn .col. 2 +}
rewind
read columns x=1 y=.ycol.
# At this point, you may want to change line thickness,
# thickness, color, dash-type, etc. For illustration,
# let's set dash type to the column number.
set dash .col.
draw curve
draw label for last curve {rpn .col. 3 + wordv}
.col. += 1
end while
}