GNUPLOT Quick-Start Guide

GNUPLOT is a command-line driven plotting program which reads in data files and produces PostScript plots of the data contained in the files. The fourth part of Programming Assignment 1 compares the performance of the "life" and "Life" programs to see which is faster. In order to do this, only a small subset of GNUPLOT commands are required, and this Quick-Start Guide will explain what these commands are in a step-by-step fashion.

  1. Creating the input files
    Since two sets of data will be plotted, two input files are required. These files will contain the timing results of running the "life" and "Life" programs. To gather this data, create two files with your favorite text editor (for example: emacs, nedit, or pico) called "life_times.txt" and "Life_times.txt".

    Programming Assignment 1 specifies that data must be collected for 1, 10, 100, 1,000, and 10,000 generations. Therefore, the programs should be run with a command line similar to this:

        [terragni] ~/eecs380/PA1 % life -i acorn -n 10000
    After the program has run, something like this will be displayed:
        Elapse time for 10000 step(s): 149122 ms
        Step to continue [10000]?
    This data should be included in the input file corresponding to the program --- in this case, "life_times.txt". Data in the input files should be arranged in two columns separated by spaces or tabs. The first column should be the number of generations, and the second column should be the run time. So each of the two input files should look like this:
        1     XXXX
        10    XXXX
        100   XXXX
        1000  XXXX
        10000 XXXX
    Where XXXX equals the length of the run time in milliseconds.

  2. Starting GNUPLOT
    After all of the values have been entered into both data files, GNUPLOT can be used to plot the data. To start GNUPLOT, type "gnuplot" at the UNIX prompt:
        [terragni] ~ % gnuplot

  3. Setting GNUPLOT options
    After starting GNUPLOT, the following will appear on the screen:
        G N U P L O T
        unix version 3.5 
        patchlevel, 27 Aug 93
        last modified Fri Aug 27 05:21:33 GMT 1993 
        Copyright(C) 1986 - 1993   Thomas Williams, Colin Kelley
        Send comments and requests for help to
        Send bugs, suggestions and mods to
        Terminal type set to 'x11'
    The line which says "gnuplot>" is the GNUPLOT prompt where GNUPLOT commands can be entered. The following command should be eneterd at the GNUPLOT prompt:
        gnuplot> set data style lines
    This command tells GNUPLOT to use solid lines to plot the data.

  4. Plotting the data to the screen
    At this point, GNUPLOT is ready to plot the data to the screen. To do so, use the plot command:
        gnuplot> plot 'life_times.txt', 'Life_times.txt'
    Note that GNUPLOT can accept a variable number of file names after the "plot" command, but this assignment only uses two.

    You should see a window open with the data plotted as two lines.

  5. Plotting the data to a file
    Now that you have verified that the data is plotting correctly, you can plot the data to a file. To do so, enter these GNUPLOT commands:
    	gnuplot> set terminal postscript color
    	gnuplot> set output ''
    	gnuplot> plot 'life_times.txt', 'Life_times.txt'
    	gnuplot> quit
    The commands tell GNUPLOT to output in color PostScript format to a file called ''. Note that any file name can be given, but '' is required for Programming Assignment 1.

  6. Viewing the PostScript plot
    After GNUPLOT has exited, the file called '' should be in the current directory. To view it, use GhostView:
        [terragni] ~/eecs380/PA1 % ghostview
    You should see the same plot as in GNUPLOT. Pull down the file menu and select Quit to exit GhostView.