navigation map

Chapters:
  1: Introduction
  2: Simple example
  3: Invocation
  4: Finer Control
  5: X-Y Plots
  6: Contour Plots
  7: Image Plots
  8: Examples
  9: Gri Commands
  10: Programming
  11: Environment
  12: Emacs Mode
  13: History
  14: Installation
  15: Gri Bugs
  16: Test Suite
  17: Gri in Press
  18: Acknowledgments
  19: License

Indices:
  Concepts
  Commands
  Variables
index.html#Top Programming.html#Programming Gri: operating system Gri: extra programs that work with Gri index.html#Top Gri: extra programs that work with Gri

10.17: Sample Resource File

The following shows a sample `~/.grirc' resource file. Much of the code here is adding new commands (see Adding New Commands.)


# 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 }

navigation map