Table of contents


NAME

pltde - Interactive graphing program for data files, functions and differential equations.

SYNOPSIS

pltde - No command line arguments.

SETUP

It is assumed that you will be connected through the Unix host with NCSA Telnet, Tektronix-capable Kermit, or via windows like X or Sunview.

To setup PLTDE under Unix, these commands should be placed in your root directory source file .cshrc:

      setenv HARDCOPY hardcopy
      setenv CRT /dev/tty
This setup will allow you to save TeK output files on disk for later conversion and printing, and to view TeK files on your MAC, IBM or SUN video terminal.

DESCRIPTION

pltde is a compiled FORTRAN program. The package PLTDE was developed during the 1980's as an interactive interface to Nelson Beebe's PLOT79, especially for 2-dimensional graphs arising in daily research.

The simplest use of PLTDE is to graph data made in a Fortran program, or obtained from some other research tool. The next likely use of PLTDE is to plot the solutions of ordinary differential equations.

The capabilities of PLTDE under Unix:

1.
Up to 40 graphs on a single plot. Up to 10,000 data items per plot curve.
2.
Import data files for plotting. Most common data files are acceptable. Internal generation of data from Fortran function subroutines or ordinary differential equations.
3.
Interactive changes of the plot, labels, label size, tick marks, axes, plot size.
4.
Stack plots, add more curves to current plot, draw lines, draw circles onto a plot.
5.
Create new data items from old ones by taking the log, smoothing, or numerical derivative.
6.
Save TeK output of final plot. Printer output is via Nelson Beebe's TEKALW filter for direct inclusion of plots into LaTeX documents or for immediate printing on the Laserwriter printer. The TEKALW filter allows a final change in plot size, pen stroke width, and white space padding prior to printing the plot.

MAIN OPTION MENU

The main options available appear below. Initially, all that is allowed is the import of data (item 1) and the help options. After data has been imported, the plot options 2,3,4,5 and the data manipulation options 13,14,15,15,17 become available. Finally, after data has been imported and one plot has been made, all menu options become available. The options are described below.
           P L T D E   M A I N    O P T I O N S
 * 1. Gather data                   13. Add column=LOG
   2. New 2d plot                   14. Add column=SMOOTHED
   3. New 3d plot                   15. Add column=NEWTON QUOTIENT
   4. New contour plot              16. Sort rows by column key
   5. New 2d stacked plot           17. Combine data (parse)
   6. Add curves to this plot      *18. Linetype and marker HELP
   7. New window                   *19. PLTDE Manual Page
   8. Add, change, move labels      20. Save DATA in a file
   9. New axes limits               21. Save TEK PLOT in a file
  10. Change ticks                 *22. Toggle wait after plot
  11. Draw straight lines          *23. Exit PLTDE (X,Q,E also exit)
  12. Draw circles                      * means option is available
 Select:

FUNCTIONS AND DIFFERENTIAL EQUATIONS

The program pltde imports data via files. To facilitate interactive import of data from functions and differential equations, the program pltde uses the following reserved names:
pltdef
user-written program that makes data file fort.99. pltde forks to this program when you enter s under item 1: `Gather data'.
fort.99
Special name of the data file used to communicate between pltde and user-written programs.

Any user-written Fortran or C executable, stand-alone program a.out can usually be renamed with the special name pltdef to become acceptable to pltde. This program must be in the current directory or the user's path in order to be accessed by pltde.

The simplest example of such a user routine is the following, which writes data for the curve y=sin(a*x) to file fort.99:

        PROGRAM PLTDEF
        WRITE(*,*)'Enter value of a'
        READ(*,*)A
        X=0.0
        WRITE(99,*) 0,2
        DO I=1,20
          WRITE(99,*) I,X,SIN(A*X)
          X=X+0.1
        ENDDO
        END
In this example, the output file fort.99 has a column of leaders and two (2) data columns. The header row `0 2' communicates the information that the file has a column of leaders and 2 data columns. An important feature of PLTDEF is the interaction with parameters (in this example, parameter A is set interactively).

A full-featured example of how to write such a user routine can be found in the makefile and sources:

   /usr/local/lib/pltde/makefile
   /usr/local/lib/pltde/pltdef.f
   /usr/local/lib/pltde/pltdef99.f

A typical use under Unix is to create a directory, copy the three source files mentioned above, then modify the sources to fit the problem at hand. The expected command line to create pltdef is either `make', or for non-makefile users:

   f77 pltdef.f -o pltdef

The source file pltdef99.f contains the main program `pltdef' and two routines for creation of the data file fort.99. Also included is a Shampine-Gordon differential equation solver. The program pltdef.f contains a line that reads "INCLUDE 'pltdef99.f'", which is how the source pltdef.f becomes a main program.

There is a source code package for language C: pltdef.c and pltdef99.c. This package uses Numerical Recipes standards for dynamic allocation and Fortran-like indexing of arrays. It contains special versions of the adaptive Bulirsch-Stoer DE solver for systems of ordinary differential equations.


SOURCE CODE FOR PLTDE

The source for PLTDE is compiled and linked with its makefile by typing make -f makefile.pltde. Required are:
            /usr/local/lib/pltde/makefile.pltde
            /usr/local/lib/pltde/pltdes.f
            /usr/local/lib/pltde/plot79   library access
The makefile creates program pltde.exe. Rename this file to pltde and copy it to the system directory, /usr/local/lib/pltde being the recommended choice. This information is provided for use by system administrators - users wanting to graph functions or differential equations should look at pltdef.f, mentioned above.

VIEWING TEK OUTPUT FILES ON SCREEN

This csh script will type out a list of TeK files so you can view the contents in a TeK window. Useful on MAC, IBM via NCSA Telnet and on a SUN using X windows.
if test $1
then
  for a in $*
  do
  echo Tek display of $a - press RETURN when done.
  echo \ 33[?38h
  cat $a
  echo \ 33\ 3
  read x
  done
else
  echo tekcat - Display tek source file in TEK window
  echo usage: tekcat filename
  echo Cannot find TEK source file $1
fi

PRINTING TEK OUTPUT ON A LASERWRITER

This csh script will create from a TEK source a new postscript file and print out the postscript file on the Apple laserwriter printer in JWB120.
if test $1
then
 $PLT/tekalw $1 $1.ps
 lpr -Pjwb120 $1.ps
else
  echo tekout - Convert TeK to Postscript and print
  echo Usage: tekout TeK-filename
  echo Cannot find TEK source file $1
fi

GATHER DATA

The data can be obtained from internally compiled subroutines, the terminal, or a data file.
   TERMINAL DATA ENTRY. This method applies for a simple graph based
   upon a few data items. The method is to type the data file
   interactively. You are prompted for the values, so we refer you to
   PLTDE for a trial run.

PLTDEF PROGRAM INTERFACE. The external program pltdef is run as a fork from pltde, which expects data file fort.99 to be produced. Data will be loaded from fort.99, upon return to pltde, provided the file exists. As a matter of course, the file fort.99 is deleted prior to each fork to pltdef.

The sample program pltdef.f (or pltdef.c) includes the code /usr/local/lib/pltde/pltdef99.f (or pltdef99.c) in order to write the required data file fort.99. The latter source contains a Shampine-Gordon solver for differential equations. In most applications, it suffices to leave the source code pltdef99.f intact and modify only the function evaluator in pltdef.f.

pltde goes through the following steps when running the user program pltdef:

1.
Delete data file fort.99.
2.
Run the program pltdef (must be an executable program).
3.
Return to pltde, open fort.99 and read in the data. This step is the same as a request `Gather data' with unit 99.

DATA FILES. The most common way to use PLTDE is to get data from a file. There are two file formats that can be used, plus some others supported by virtue of skipping initial lines and optionally leaders in column 0.

PLTDE FORMAT. The format is a matrix of numbers N row by M columns with column 0 a column of integers are not used as data (they are sequence numbers). Row 1 should start with integer digit 0, followed by some spaces, then the value M. Note that column 0 causes confusion as to the number of columns: the file has M+1 columns total, numbered 0 to M (not 1 to M+1). Below is a data file for a 4x3 matrix. Note in particular the HEADER row which tells how many columns are present, and the column of LEADERS or sequence numbers. Technically, the data file for a 4x3 matrix has 5 rows and 4 columns due to the presence of the HEADER row and LEADERS column. 0 3 1 1.0 2.5 4.1 2 1.1 2.6 4.7 3 1.2 2.3 4.6 4 1.3 2.6 4.4 To make it possible to include other data sets in one file, PLTDE has the convention that a row starting with 1.0e32 or larger is a sentinel to switch data sets. For example, the following is a file for two data sets, which will be plotted as 2 distinct curves in the TeK plot.

0 3 1 1.0 2.5 4.1 This plots as curve set 1 2 1.1 2.6 4.7 3 1.2 2.3 4.6 4 1.3 2.6 4.4 0 1.e32 0.0 0.0 Sentinel line with 1.0e32. 1 2.0 2.3 4.2 This plots as curve set 2. 2 2.1 2.7 4.3 Still, only 3 columns of 3 2.2 2.9 4.1 data for pltde! 4 2.3 2.4 4.0

GRAPH FORMAT. The Unix GRAPH program accepts data files with 2 columns, representing the X and Y values for a data set. PLTDE accepts such files also, with the caveat that items in row 1 contain decimal points. Here's an example for plotting y = 2x+1: 0.0 1.0 For predictable results, row 1 .1 1.2 should contain decimal points. .2 1.4 .3 1.6 .4 1.8 .5 2.0 .6 2.2 .7 2.4 .8 2.6 .9 2.8 1.0 3.0

OTHER FORMATS. The program can skip initial lines and include or exclude the column of leaders. Furthermore, you can specify how many columns to read. This may not be perfect for some kinds of data files. It is suggested that foreign data be converted prior to running PLTDE (this might be done in the external program pltdef).


NEW 2D PLOT

To initiate a new plot, data must have been loaded previously. The columns of data are numbered from 1 to 40, corresponding to an internal 2-dimensional array (matrix) with 10,000 rows and 40 columns. Your data may use only a small portion of this array. You are expected to keep track of the meaning of the data columns.

The order of entry is important. For example, entering 1 3 means you want to use column=1 for the x-axis and column=3 for the y-axis, whereas entering 3 1 plots the inverse graph (which may not be what you wanted).

More than 1 curve can be plotted on a single TeK screen. The curve combinations are accepted until a blank line is entered.


NEW 3D PLOT

The 3d features of PLTDE are not really very useful, but they presently exist in order to fill an occasional need. Use at your own risk!

NEW CONTOUR PLOT

This is really a simple contour plot for data z=f(x,y), independent of the other features in PLTDE. In particular, you can save the plot as a TeK file, but cannot add labels, rescale axes, change the window, or anything else.

A contour plot is made of Z=f(X,Y) on a rectangle in the plane. Assumed are M=N*N values of Z obtained from N divisions in the X and Y directions (40 < N < 100 is best).

The ordering of Z-values in the data file is important. Starting at a rectangle corner, write the Z-values with an outer loop on Y, and an inner loop on X. For an example of how this is done, the following Gaussian Well data will plot an interesting contour plot:


C Gaussian well data for contour plot
C  See DEM40 in plot79 sources
C
      PROGRAM GWELL
      DATA                NX        / 97 /
      DATA                NY        / 97 /
      DATA                NZ        / 41 /
      EX(IARG) = 0.0667*FLOAT(IARG-KX)
      WY(JARG) = 0.0487*FLOAT(JARG-KY)
      KX = (6*NX)/10
      KY = (4*NY)/10
      DO 20 J = 1,NY
           DO 10 I = 1,NX
                X1 = EX(I)
                X2 = WY(J)
                R1 = EXP(-X1*X1)
                R2 = EXP(-X2*X2)
                RR = EXP(-0.25*(X1-X2)*(X1-X2))
                WRITE(*,*) TANH(0.4*(-2.0*R1-2.0*R2+RR))
10         continue
20    continue
      END

Not in particular that the data file for the Gaussian Well will have just one column: no X and Y values need to be in the data file. PLTDE will gather data from the data file as a foreign file with 1 data column. The contour plot option will produce the TeK output as in the plot79 DEMO40 example.


NEW 2D STACKED PLOT

This option exists in order to plot curves shifted by a fixed factor. It reduces to New 2d plot if the number of curves is 1. Otherwise, the ticks on the y-axis get changed to accommodate the multiple curves to appear on the plot.

This technique applies to snapshots of similar curves, for example, the cross-sections of a surface z=u(x,y) for certain values of y, plotted in 2d as z versus x.


ADD CURVES TO THIS PLOT

The curves already in the TeK plot are retained. Any new data must be loaded before starting this option. Refer to New 2d plot above for information on how the plot information is to be entered.

NEW WINDOW

This option shrinks or expands the physical size of the plot. Also included is a way to shift the plot up or down within the TeK window and change the length of the x and y axes.

There are two data entries in this option. Both require the entry of four (4) real numbers.

The first data entry selects the window for plotting. Expect the data to be clipped if it does not appear in this window of x and y values. Example: Data item x=2.0 y=1.0 will not be plotted if the window is set to 0 <= x <= 1.5, 0 <= y <= 2.0 by the data entry 0 1.5 0 2.0.

The second data item selects the length and placement of the axes in the plot. Expected are 4 numbers like 0.2 0.9 0.15 0.85, all on one line. The numbers supplied select a subrectangle of [0,1]x[0,1] on which to set the axes in the plot. The meaning for the example is: place the x-axis on [0.2,0.9] and the y-axis on [0.15,0.85], so that the axes use 70 percent of the available space ([0.2,0.9] is 70 percent of [0,1]).


ADD, CHANGE and MOVE LABELS

Two kinds of labels can be added to the plot.

The first kind of label is an axis label. This will be placed parallel to the axis in question and centered. A common data entry is a blank line for the label, which erases the label. Other changes are scaling of the font so that the label matches the graph. An axis label may contain the case switch syntax <> of plot79 and also $N or $n to introduce a newline into the title for multi-line titling. Axis labels cannot be repositioned. If you need to do it, then consider the other kind of label below.

The second kind of label is a FREE label, placed at any coordinate in the TeK window. The data entry consists of the label itself, which is a string of characters obeying PLOT79 rules, which allow for upper and lower case characters. Multiline labels using $N or $n newline markers are not supported in this mode (although they are supported in the axes labels described above).

The coordinates used to place the label refer to the ticks on the axes. You may be able to place a label outside the tick limits. For example, it is routine to set a label above the Y-axis and to the right of the X-axis. For example, if the x-scale is 0 to 24, then numbers like -0.5 to 24.5 may be acceptable data. This all depends on the window size and the size of the font being used. Experiment - it might work.

Options exist to modify the label title and position. This works like adding a new label, except data entry has been reduced by defaults already set from the previously entered label.

Finally, a label can be removed. This is often needed after rescaling the window or zooming the axes. Practise will make this seem a little easier: the ordering of events suggested is to get the window size right before adding any labels.


NEW AXES LIMITS

This option allows you to zoom in on a relevant portion of the curve, or to chop off extraneous or uninteresting portions of the plot.

The X and Y axes in a 2d plot are equipped with a default scaling and upper and lower limits. This can be changed in order to display relevant portions of the plot. This change does not change the physical length of the displayed axis: it only changes the numbers under the ticks. Since curves are plotted based on the window of data items allowed by the tick marks, the effect is to chop off the graph.

This option reset by the New Window option, so you may need to redo it after a window and viewport change. Certain changes will not have the desired effect, so experimentation is often needed to get the desired result in the plot.

The basic data entry for the change is 4 numbers on a single line, or a blank line to abort and keep the old values already in effect. The idea to keep in mind is that you cannot by this entry increase the size of the viewport, so all that is allowed, in theory, is a reduction in the axis length of the plot.


CHANGE TICKS

The minimum number of ticks is 2 per axis. The ticks are evenly distributed and the numbers to appear below the ticks are calculated from the interval endpoints. With clever resets of the endpoints, the amount of the screen dedicated to axis numbering can be minimized.

Some undesirable side effects of tick mark changes are huge numbers appearing along the axes. Experimentation can minimize the size of the numbers.


DRAW STRAIGHT LINES

The lines are drawn using screen coordinates from the axes of the plots. For example, if the x-axis is scaled from tick mark 0 to tick mark 24, then you may enter x-value 0 to 24. Ditto for y-values. A total of four (4) values must be entered, in the order

            x1   x2   y1   y2
and all on one line. For example, to draw a line from (0,1) to (2,4) you would enter
            0    2    1    4
and press RETURN to plot. More than one line can be entered per session, so that several lines get plotted on the TeK screen.


DRAW CIRCLES

Any number of circles can be added to the plot. The axes will be scaled accordingly, and surprises sometimes appear because the curve originally plotted will appear to be different under the new scales along the axes.

The data entry expected is the circle center (x,y) and the radius r. All three numbers are entered on one line, separated by spaces. A blank line aborts, or if circle data has been entered, a blank line initiates the plot. An abort after data entry is effected by entering asterisk (*) as the first character of the line.


ADD COLUMN=LOG

This option exists to test the theory that data is exponential or power modeled. The option adds another column of data to the internal 10,000x40 matrix consisting of the natural logarithm of the given column. Some care is exercised to avoid bad data (negative or zero logarithm argument), but it's not foolproof.

ADD COLUMN=SMOOTHED

The internal 10,000x40 matrix is equipped with a new column of data, made from the specified columns by fitting the data with a spline model of order 1, 2, 3, or 4 (chosen interactively). The coefficients of the fit are appended to the file fitter.dat in the connected directory.

This option originated with the need to smooth out experimental data and it remains a useful tool for handling noisy data sets.


ADD COLUMN=NEWTON QUOTIENT

The difference quotient used is a backwards difference or Newton Quotient based upon the current data item and the data item one index backwards in the data set. It is:
                  y(i) - y(i-1)
                  -------------
                  x(i) - x(i-1)
This is considered to be the numerical derivative of the data, (although there may be other and better ways to differentiate the data set).

The data entry for this option consists of the two columns to use for the X and Y data, historically entered as Y first then X, all on one line. Example: 2 1 makes a new data column in the 10,000x40 internal matrix by doing Newton quotients with y-values from column=2 and x-values from column=1.


SORT ROWS BY COLUMN KEY

Data sets are graphed by connecting points, so it is essential in many cases to have the x-axis values sorted. This option allows the sorting of the internal 10,000x40 matrix data so that the given column is numerically sorted from smallest to largest. This amounts to re-arranging the matrix rows to achieve the sorted order in the given column.

The data entry consists of specifying the column. Note that this option shuffles the rows around, so that further plots are using shuffled data and may not come out as expected. Often, the sort option has to be re-applied to each abscissa as multiple plots are scheduled.


COMBINE DATA (PARSE)

This parser is not implemented at present, due to lack of interest, and undocumented features of the parser (which was written by Chip Petersen in the 1980's).

The idea of the parser is to produce a new data column in the 10,000x40 internal matrix by performing interactively specified operations on the data columns of the matrix. Most of what was done in the 1980's can be done easily by the programming language AWK, hence there is not much practical interest in making the parser work.

A more appropriate function for the parser is to provide a way to type in a function definition interactively. This is especially interesting for systems of differential equations. What we need to be able to implement this idea is a good function parser written in language C or Fortran 77.


LINETYPE AND MARKER HELP

The help files for the linetype and curve markers are printed. In print once again:
L I N E T Y P E          M A R K E R   S T Y L E S
0  solid curve           1:dot                11:swiss cross
1  dashed lines          2:+                  12:bell
2  mark points only      3:*                  13:paragraph
3  plot 3-D solid        4:circle             14:dagger
   lines with hidden     5:x                  15:double dagger
   intersections         6:square             16:spade
                         7:triangle           17:heart
                         8:crosshair          18:diamond
                         9:five-point star    19:club
                         10:six-point star    20:shamrock

PLTDE MANUAL PAGES

An online help file which replaces having the printed manual handy. This is the manual page, equivalent to man pltde typed at the Unix prompt. All commands match the paging program selected in your account (usually the unix programs called more and less). If you are new to Unix: Q quits the manual page, SPACEBAR moves one page ahead.

SAVE DATA IN A FILE

The plot data is saved in a file given by name or unit number. The file is looked up to make sure that an existent file does not accidently get clobbered.

This file is ascii data editable in emacs or pi or vi editors - it is NOT a TeK file that can be used to print out the plot.

The required data entry is a file name or unit number. A blank line quits to the main menu without saving the plot data.


SAVE TEK PLOT IN A FILE

The data to be saved is a TeK plot and only the last one appearing one screen will be saved. Technically, plot79 saves everything, but the routines have been modified to allow only one saved HARDCOPY file at a time. This means that HARDCOPY files won't build up in your directory unless you specifically ask for a plot to be saved. Finally, the name of the plot file must be supplied, so there is a chance to force your own naming conventions on the TeK output file, including a directory location for storing the plots.

The data entry required is a file name (unit number not used). The name is checked for existence, so that you do not accidently clobber a file with the same name.

The usual convention of a blank file name (RETURN only) applies to abort from this option and return to the main menu.


TOGGLE WAIT AFTER PLOT

The IBM and MAC microcomputers that run NCSA Telnet or Kermit have the ability to display TeK plots automatically. Unfortunately, there is no cute way to swap between the VT100 screen and the TEK screen, automatically. It must be done manually by the user.

To regulate this swapping of screens, PLTDE will wait for the entry of a RETURN key after the plot completes. The toggle on the main menu turns this feature on/off. It is initially off for the Unix version because of the heavy use of X-windows, which does not require a manual screen switch. Remote users on MAC or IBM microcomputers may wish to compile their private version of PLTDE to have the wait after plot toggle initially ON.


EXIT PLTDE

To exit PLTDE normally enter X or Q or E.

If you want to suspend the Unix image of PLTDE, then press ctrl-Z during its execution. The fg command under Unix can be used to restart PLTDE where you left off (it will take a RETURN key after restart to re-display the main menu).

Reasons for suspending PLTDE include the desire to read mail, edit a data file, run a Fortran program to generate more data, etc, all without losing your sequencing of plots. This is especially useful on a 2400 baud serial line.


FILES

/usr/local/bin/pltde
executable file
/usr/local/lib/pltde/pltde.tex
manual source code in LaTeX.
/usr/local/lib/pltde/pltde.man
manual source code in nroff.
/usr/local/lib/pltde/pltdes.f
Pltde Fortran source file, complete.
/usr/local/lib/pltde/pltdef.f
Sample Fortran function source file.
/usr/local/lib/pltde/pltdef99.f
Rest of pltdef.f needed to make a main program.
/usr/local/lib/pltde/pltdef.c
Sample C source code equivalent to pltdef.f. See also pltdef99.c for the DE solver and file interface.
/usr/local/lib/pltde/makefile
Unix Makefile source for assembling the application pltdef.
/usr/local/lib/pltde/makefile.pltde
Unix Makefile source for assembling the application pltde.

BUGS

Some graphics commands do not tolerate bad input, so there is always the possibility of crashing the program with bad data.

Only a limited class of data files can be imported to pltde.


HISTORY OF PLTDE

The original sources were developed by Chip Petersen. Jim Keener added features and functionality during the 1980's. The 1990 conversion to Unix was done by Grant Gustafson.

The source code is available. Contact the author by email for distribution requirements.


AUTHOR

James P. Keener

115 JWB Math Dept

University of Utah

Salt Lake City, UT 84112

Tel: (801) 581-6638

email: keener@solitude.math.utah.edu

email: keener@math.utah.edu