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 HandlingData.html#HandlingData Gri: ignoring columns Gri: combining columns index.html#Top Gri: combining columns

8.12.3: Algebra on column data

Suppose the file contains (x,y), but you wish to plot 2y times x. You could do the doubling of y within Gri, as


open file
read columns x y
y *= 2
draw curve

or you could use a system tool, e.g. gawk, as in this example (see Awk).


open "gawk '{print($1,2*$2)}' file|"
read columns x y
draw curve

The latter is preferable in the sense that it is more powerful. The reason for this is that Gri allows you to manipulate the x and y columns, using so-called RPN mathematics (see rpn Mathematics), but you cannot blend the columns. For example, you cannot easily form the ratio y/x in Gri. (Actually, you can, by looping through your data and doing the calculation index by index, but if you knew that already you wouldn't need to be reading this section!) Such blending is trivial in the operating system, though, as in the following Gawk example (see Awk).


open "gawk 'print {($1, $2/$1)}' file |"
read columns x y
draw curve

navigation map