Gri: simple example

Simple example 1: Introduction 2: Simple example 3: Fancy example 4: Running Gri 5: Programming Gri 6: General Issues 7: X-Y Plots 8: Contour Plots 9: Image Plots 10: Examples 11: Handling Data 12: Gri Commands 13: Gri Extras 14: Evolution of Gri 15: Installing Gri 16: Gri Bugs 17: System Tools 18: Acknowledgments 19: License 20: Newsgroup 21: Concept Index | # 2: Simple Gri Program and How to Run it This chapter introduces Gri with a common example: a x-y graph. The example is discussed in detail later see X-y Plots. The data files and command files here and throughout the manual should be available to you in a directory ``.../gri/examples`' on unix machines. ## 2.1: Gri Command file Here is a Gri command file to plot a linegraph of a set of (x,y) data, stored as space-separated columns in a file called ``example1.dat`':
    # Example 1 -- Linegraph of data in separate file
    open example1.dat     # Open the data file
    read columns x y      # Read (x,y) columns
    draw curve            # Draw data curve
    draw title "Example 1"# Title above plot
    quit                  # End the plot
The first line is a comment, as are all things following double slashes. (An exception to this double-slash rule is made within strings contained within the double-quote character ``"`'. This allows ``sed`' system commands to work as expected; see System.) The other lines are Gri command lines; see X-y Plots. for more explanation. ## 2.2: Data File The data file ``example1.dat`' looks like:
    0.05 12.5  # first point
    0.25 19    # second point
    0.5  15    # third point
    0.75 15    # ... you get the idea!
    0.95 13
Note that spaces (or tabs) separate numbers. Any data line may have a comment on it, just as any command line may. ## 2.3: Running The Command File Type ``gri example1.gri`' at the system prompt. Gri will create a PostScript file called ``example1.ps`'. For details on running Gri see Invoking Gri.. ## 2.4: Output Graph The output PostScript file is called ``example1.ps`'. It looks something like the miniature shown above. Click the plot to enlarge it.) To view Gri output, use your favorite PostScript previewer; see Viewing. Note that in the above example, Gri automatically chose reasonable scales for the axes, based on the range of the data. The next chapter illustrates that Gri also gives you control over such things.