home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / graphfor.zip / GRAPH.DOC < prev    next >
Text File  |  1990-05-04  |  33KB  |  847 lines

  1.  
  2.  
  3.  
  4.  
  5.                      Graph for Fortran v2.0
  6.  
  7.  
  8.               Graph plotting on dot matrix printers
  9.              =======================================
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18. ********************************************************************
  19.  
  20.       SHAREWARE NOTICE            Copyright (C) D.I. Hoyer, 1990.
  21.      ==================
  22.  
  23.      If you find these Fortran subroutines useful, please register
  24.      by sending US$30-00 or Aus$40-00 to the address below :-
  25.  
  26.                     David I Hoyer
  27.                     31 Rossian Place
  28.                     Cherrybrook  NSW 2120
  29.                     AUSTRALIA
  30.  
  31.      This subroutine library is a shareware product. Copies of the 
  32.      original unmodified programs and manual on disk may be made 
  33.      and distributed, as long as they are not charged for. You may 
  34.      not modify the source code or manual except for your personal 
  35.      use. Registrants will receive a free update.
  36.  
  37.  
  38. *******************************************************************
  39.  
  40.      No responsibility is accepted for any errors in this software, 
  41.      or for any loss or damage resulting from using it.  
  42.  
  43. *******************************************************************
  44.                                                                Page 2
  45.  
  46.  
  47.                             C O N T E N T S
  48.                            =================
  49.  
  50.                                                                Page
  51.  
  52.     Shareware notice   .  .  .  .  .  .  .  .  .  .  .  .  .  .  1
  53.  
  54. 1.  Introduction .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  3
  55.  
  56. 2.  Description of disk contents   .  .  .  .  .  .  .  .  .  .  4
  57.  
  58. 3.  Some quick demonstrations   .  .  .  .  .  .  .  .  .  .  .  5
  59.  
  60. 4.  Using GRAPH to plot graphs from a data file   .  .  .  .  .  6
  61.       a)  Plotting the demo graphs supplied .  .  .  .  .  .  .  6
  62.       b)  Plotting your own graphs    .  .  .  .  .  .  .  .  .  6
  63.       c)  Data file specifications for GRAPH.for  .  .  .  .  .  7
  64.  
  65. 5.  Using the GRAPHLIB subroutines to get your own   .  .  .  .  8
  66.       programs to plot graphs 
  67.  
  68. 6.  Limitations  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  .  9
  69.       a)  Graph size & Memory   .  .  .  .  .  .  .  .  .  .  .  9
  70.       b)  Function parameters   .  .  .  .  .  .  .  .  .  .  .  9
  71.  
  72.  
  73.  
  74. Appendix A.  Definition of Fortran names used  .  .  .  .  .  .  10
  75.  
  76. Appendix B.  Symbols and line types.  .  .  .  .  .  .  .  .  .  12
  77.  
  78. Appendix C.  Sample list of standard user-defined functions   .  13
  79.  
  80. Appendix D.  A sample data file for use with GRAPH   .  .  .  .  16
  81.  
  82.                                                                Page 3
  83.  
  84.                  Graph plotting on dot matrix printers
  85.                 =======================================
  86.  
  87. 1.  Introduction
  88. =================
  89.  
  90.      Print out this manual by typing:
  91.      copy graph.doc prn
  92.  
  93.      This collection of Fortran subroutines will make it simple for 
  94.      you to plot high quality scientific and engineering graphs on 
  95.      dot matrix printers which have the ability to print graphics. 
  96.      These subroutines can easily be incorporated into any Fortran 
  97.      program, so that your own programs can automatically print 
  98.      high resolution graphs as part of the program output. Also 
  99.      included is a sample main program to illustrate the use of the 
  100.      subroutines. This sample program works as a stand-alone graph 
  101.      plotter for plotting graphs from a data file. So, as an 
  102.      alternative  to incorporating the graph plotting subroutines 
  103.      into your own programs, you could instead get your program to 
  104.      simply write a suitable data file to disk for plotting out 
  105.      later, using the sample main program supplied (GRAPH.for).
  106.  
  107.      Some of the features available are :
  108.  
  109.      * high or low resolution options,
  110.      * graph can be plotted vertically or horizontally on the page,
  111.      * linear or logarithmic axes, with labelling of axes,
  112.      * overlaying grid lines on the graph, in various line styles,
  113.      * drawing lines in different styles (solid, dotted etc.),
  114.      * plotting points, with a large range of symbols to choose from,
  115.      * joining points with straight lines or a cubic spline,
  116.      * plotting user-defined functions,
  117.      * passing a list of parameters to the user-defined functions,
  118.      * placing text of different sizes and orientations on the graph,
  119.      * clearing an area of the graph, with optional border
  120.      * automatic generation of legend tables to describe each curve.
  121.  
  122.      Read through this manual and print out all the demonstration 
  123.      graphs before using the programs for your own applications. 
  124.      That way you will be more familiar with the capabilities of 
  125.      the programs.
  126.  
  127.                                                                Page 4
  128.  
  129. 2.  Description of disk contents
  130. =================================
  131.  
  132.      Your disk should contain the following files :-
  133.  
  134.      BROWSE  .exe    Program for browsing through documents & manuals.
  135.  
  136.      BROWSE  .hlp    Help file used by browse.exe
  137.  
  138.      README  .doc    Text document with a description of the overall
  139.                      use of the programs, plus a brief description of
  140.                      each file.
  141.  
  142.      GRF     .bat    Sample batch file for executing GRAPH with a
  143.                      data file.
  144.  
  145.      GRAPH   .doc    User's manual.
  146.  
  147.      GRAPH   .for    Sample main program for plotting graphs on dot
  148.                      matrix printers, from data files.
  149.  
  150.      GRAPHLIB.for    Subroutine library of graph plotting
  151.                      procedures for plotting on dot matrix printers.
  152.  
  153.      GRAPHFNS.for    Function segment containing user-defined
  154.                      functions.
  155.  
  156.      GRAPH   .nnn    Sample data files to use with GRF.bat
  157.                      (nnn is a number 001 to 999) :-
  158.  
  159.           GRAPH.001  General graph demo (vertical and Hi-res).
  160.           GRAPH.002  Same as .001, but horizontal and Lo-res format.
  161.           GRAPH.003  Graph of several standard functions.
  162.           GRAPH.004  Demo of text, graph symbols and line styles.
  163.                                                                Page 5
  164.  
  165.  
  166. 3.  Some quick demonstrations
  167. ==============================
  168.  
  169.      For a quick and easy demonstration of some of the graph
  170.      plotting capabilities of the programs follow the steps listed
  171.      below. You need a Fortran 77 compiler to compile the program.
  172.      The Fortran programs should be usable on any computer which
  173.      has a Fortran 77 compiler and a suitable dot matrix printer,
  174.      though this section assumes you are using an MS-Dos or PC-Dos
  175.      operating system (for the GRF.bat batch file).
  176.  
  177.      The graphs should print correctly on printers such as the IBM
  178.      Proprinter, and most Epson and Star dot matrix printers. If
  179.      you have a different printer, try this procedure first. If the
  180.      graph does not print correctly then you will have to modify
  181.      subroutine PRTGRF in disk file GRAPHLIB.for. If you have less
  182.      than 310 kBytes of available RAM, you may have to change the
  183.      DIMENSION statement in the sample main program GRAPH.for; and
  184.      you may not have enough memory to print some the demonstration
  185.      graphs.
  186.  
  187.      To print out GRAPH.001:
  188.      -----------------------
  189.  
  190.      a)   Insert the disk containing the GRAPH programs into the 
  191.           default disk drive, or if you have a hard disk then copy 
  192.           them to the hard disk.
  193.  
  194.      b)   Compile the program GRAPH.for using your Fortran 77 
  195.           compiler. An executable file called GRAPH.exe should be 
  196.           created by the compiler.
  197.  
  198.      c)   Make sure the dot matrix printer is connected and 
  199.           switched on.
  200.  
  201.      d)   At the Dos command line type :
  202.           grf 001
  203.  
  204.      e)   Wait a minute or two while the graph is 'plotted' in the 
  205.           computer's memory, after which it will be directed to the 
  206.           printer and printed in high resolution.
  207.  
  208.      The above procedure uses the supplied batch file GRF.bat to
  209.      print out the graph defined in the demonstration file
  210.      GRAPH.001. Several other graph demonstration files are
  211.      supplied on disk; these are named GRAPH.nnn, where nnn is a
  212.      number. Just type   grf nnn   to print graph GRAPH.nnn
  213.      (assuming that you have already compiled the sample main
  214.      program GRAPH.for).
  215.                                                                Page 6
  216.  
  217. 4.  Using GRAPH to plot graphs from a data file
  218. ================================================
  219.  
  220.      The simplest way to plot graphs on a dot matrix printer is to
  221.      create a data file, and use the GRF.bat batch file to execute
  222.      it. Remember to compile the GRAPH.for program before you try
  223.      to execute it, using a Fortran 77 compiler (as described in
  224.      Section 3).
  225.  
  226.      The data file can be created using a word processor in non-
  227.      document mode, or it can be written by one of your own
  228.      programs as a simple ASCII data file. If you know how to
  229.      program in Fortran it should be a simple matter to tailor
  230.      GRAPH.for to your own requirements if necessary.
  231.  
  232.      A graph data file is created for input to the program. The
  233.      program then 'plots' the graph in memory, as a matrix of
  234.      points, before directing it to the printer. The maximum size
  235.      graph which can be plotted from the program GRAPH.for is 20 x
  236.      25 cm, but this can easily be changed by changing the
  237.      DIMENSION statement in GRAPH.for. The program is rather memory
  238.      intensive - for example the 20 x 25 cm size requires at least
  239.      310 kBytes of RAM for Hi-res plotting (though only about 80
  240.      kBytes for Lo-res).
  241.  
  242.  
  243.      a)  Plotting the demo graphs supplied
  244.      --------------------------------------
  245.  
  246.      To get started, try plotting some or all of the demonstration
  247.      graphs supplied with the programs after you have compiled the
  248.      program GRAPH.for with your Fortran 77 compiler. The demo
  249.      graphs are named GRAPH.nnn, where the nnn refers to a number
  250.      from 000 to 999. For example, to plot the graph described by
  251.      file GRAPH.001, type :
  252.  
  253.      grf 001
  254.  
  255.      Make sure the printer is switched on. The graph will be
  256.      'plotted' in memory first, which could take a minute or two,
  257.      before being directed to the printer. Repeat this for all the
  258.      graph demos, so that you will have an idea of the capabilities
  259.      of the subroutines.
  260.  
  261.      b)  Plotting your own graphs
  262.      -----------------------------
  263.  
  264.      To plot you own graphs from program GRAPH you will need to
  265.      create data files similar to the demo files described above.
  266.      Have a look at some of the demo files, and you will see that
  267.      they are simply lists of numbers and text. These provide the
  268.      program with information on the size and style of the graph,
  269.      and the data to be plotted. The program GRAPH.for reads the
  270.      data file, and passes the appropriate parameters to the
  271.      subroutines which do the plotting. It has been written very
  272.      simply, to make it easy for you to re-write to your own
  273.      requirements if you need to. As a result, the data
  274.      file is expected to be in a rigid format, so if you are going
  275.      to use the original GRAPH.for program, your data file must
  276.      conform to the specifications given in (c) below.
  277.                                                                Page 7
  278.  
  279.      c)  Data file specifications for GRAPH.for :
  280.      --------------------------------------------
  281.  
  282.      The data file to be read by the supplied sample main program
  283.      GRAPH.for must conform to the specifications listed below. A
  284.      detailed discussion of the demonstration data file GRAPH.001
  285.      is given in Appendix D. You can always re-write the main
  286.      program to put the data entry into a more convenient form for
  287.      your own applications. If you plan to use GRAPH.for for
  288.      plotting your own graphs then the data file you write must
  289.      conform to the following specifications:-
  290.  
  291.      1. Maximum 80 characters per line (standard Fortran input).
  292.      2. All numbers must be within fields of width 10 columns.
  293.      3. Text occupies rest of line to column 80.
  294.      4. If more than 8 numbers are required, use as many lines as
  295.         necessary. (eg. for entering more than 8 function parameters)
  296.  
  297.  
  298.      The names used are defined in Appendix A. Once you have read
  299.      through them, most of them will be self-explanatory.
  300.  
  301. line 1 : igrprt, xl, yl, glabel.       {print axes, x & y-axis lengths,
  302.                                         heading}
  303.  
  304. line 2 : xmin, xmax, ymin, ymax.       {min & max values for plotting}
  305.  
  306. line 3 : ndivx, nsdivx, ndpx, xlabel.  {x-axis specs, divisions & label}
  307.          (ndivx = 0 for log. scales)
  308.  
  309. line 4 : ndivy, nsdivy, ndpy, ylabel.  {y-axis specs, divisions & label}
  310.          (ndivy = 0 for log. scales)
  311.  
  312. line 5 : ivh, lohi, ioff, igrid, nsets, legpos.  {graph style & data sets}
  313.  
  314.  
  315. For each of the NSETS sets of data add the following lines...
  316.  
  317. line a : npts, ltyp, mark, msize, legend.
  318.  
  319. line b : if npts>0     [Plot a series of npts data points]
  320.                    enter --- x, y     (1 line for each data pair)
  321.  
  322.          if npts=0     [Plot user-defined function number ifn]
  323.                    enter --- 1st line:  ifn, nparms, x1, x2
  324.                              2nd line:  p(i) for i=1 to nparms
  325.  
  326.          if npts=-1    [ Write a text string starting at (x,y)    ]
  327.                        [ (x,y) defines the centre of upper case X ]
  328.                    enter --- 1st line:  iori, itxsiz, x, y
  329.                              2nd line:  strng
  330.  
  331.          if npts=-2    [ Clear a rectangular area of the graph  ]
  332.                        [ (x1,y1)=top left, (x2,y2)=bottom right ]
  333.                    enter --- 1st line:  x1, y1, x2, y2
  334.                                                                Page 8
  335.  
  336. 5.  Using the GRAPHLIB subroutines to plot graphs from your own programs
  337. ========================================================================
  338.  
  339.      It is a simple matter to get your own Fortran programs to
  340.      print graphs on dot matrix printers which have plotting
  341.      facilities. Read through sections 3 and 4 first to get an idea
  342.      of how the sample main program works. For you own program you
  343.      simply need to assign values to the variables described in the
  344.      above section (ie. the variables which are read from a data 
  345.      file in the sample main program supplied). You also need to 
  346.      DIMENSION the arrays IGRAPH and P in your main program 
  347.      according to the maximum size graph you will be printing out,
  348.      and the maximum number of parameters to be passed to the user-
  349.      defined functions. Details are in the source code file 
  350.      GRAPH.for. If you want to add your own user-defined functions, 
  351.      you can do this by modifying the file GRAPHFNS.for. Then your 
  352.      program calls the following subroutines :
  353.  
  354.       PREP(... to prepare axis sizes, scaling factors, and other 
  355.                details.
  356.  
  357.       AXES(... to plot axes for the graph (optional).
  358.  
  359.       PLOTD(...for each set of data to be plotted. A 'set of data'
  360.                is defined as a string of text, a user-defined 
  361.                function plotted between specified values on the x-
  362.                axis, or a set of data points (which may be 
  363.                connected by a line or smooth curve).
  364.  
  365.      If your program is to plot more than one graph, remember to 
  366.      clear the previous graph before starting to plot the next one, 
  367.      using :-
  368.  
  369.       CLRGRF(...
  370.  
  371.      Finally, you will also need to include the subroutine library 
  372.      and function segment with the statements:
  373.  
  374.       INCLUDE 'GRAPHLIB.for'
  375.       INCLUDE 'GRAPHFNS.for'
  376.  
  377.  
  378.      For more advanced programming or plotting, you may want to 
  379.      call some of the other subroutines in the library, or you may 
  380.      want to modify them for your personal use. The subroutines
  381.      should have sufficient comment lines to enable you to do this 
  382.      if you are reasonably familiar with programming in Fortran.
  383.                                                                Page 9
  384.  
  385. 6.  Limitations
  386. ================
  387.  
  388. a)  Graph size & Memory
  389. ------------------------
  390.  
  391.      The size of graph which you can plot is limited only by the 
  392.      paper size on your printer, and the amount of memory (RAM) 
  393.      available in your computer. The maximum size is set by the 
  394.      DIMENSION statement for array IGRAPH in the main program. For 
  395.      a graph of 20 x 25 cm (8" x 10"), about 310 kBytes of RAM is 
  396.      required for Hi-res, and about 80 kB for Lo-res.
  397.  
  398.      If the x- or y-axis lengths specified are too long for the 
  399.      DIMENSION'ed size of IGRAPH, the program will terminate with 
  400.      an error. 
  401.  
  402.  
  403. b)  Function parameters
  404. ------------------------
  405.  
  406.      The maximum number of parameters which can be passed to the 
  407.      user-defined functions in FUNCTION FGRAPH is specified by the 
  408.      DIMENSION of array P() in the main program.
  409.  
  410.                                                                Page 10
  411.  
  412. Appendix A.  Definition of Fortran names used
  413. ==============================================
  414.  
  415. glabel = Graph heading.
  416.  
  417. igrprt = 1 to print axes,
  418.          0 to suppress printing of axes.
  419.  
  420. ifn    = Function number (pre-compiled in GRAPHFNS.for) to plot if npts=0.
  421.  
  422. igrid  = 0 to print axes without grid lines,
  423.          1 to n for grid lines of type ltyp (try igrid=2).
  424.  
  425. ioff   = Offset. This is the number of blank spaces printed 
  426.          between the left margin and the graph on the page, so 
  427.          that the horizontal position can be set.
  428.  
  429. iori   = Orientation for text plotting. 
  430.          1=normal, 2=vertical bott-top, 3=upside down, 4=top-bott.
  431.  
  432. itxsiz = Size of text to be plotted (2 = normal).
  433.  
  434. ivh    = 1 for vertical (portrait) printout, 
  435.          2 for horizontal (landscape).
  436.  
  437. legend = Text to describe each data set in the legend table. 
  438.          Blank to omit this data set from the legend table.
  439.  
  440. legpos = Position of legend table. [default = 1]
  441.          1=top left,     to 4=top right,
  442.          5=bottom left,  to 8=bottom right.  
  443.  
  444. lohi   = 1 for low-resolution plot (plots at 4x speed), 
  445.          2 for hi-res (much higher quality).
  446.          Hi-res is 120 dots per inch (dpi) across, by 144 dpi down,
  447.          printed as interleaved rows 1/144" apart. 
  448.          Lo-res is 60 by 72 dpi.
  449.  
  450. ltyp   = Line type for joining points, 1-5. 
  451.          (see table in Appendix B).
  452.  
  453. mark   = Symbol to be plotted at each point. 
  454.          1 to 12 for special symbols, 32 to 126 for ASCII character.
  455.          (see table in Appendix B).
  456.  
  457. msize  = Size of mark (1,2,3,...). Try 2 or 3 to start. 
  458.  
  459. ndivx  = Number of main divisions along x-axis. Axis values are 
  460.          printed between main divisions.
  461.          Set ndivx = 0 to specify logarithmic x-axis scale.
  462.  
  463. ndivy  = Number of main divisions along y-axis. Axis values are 
  464.          printed between main divisions.
  465.          Set ndivy = 0 to specify logarithmic y-axis scale.
  466.  
  467. ndpx   = Number of decimal places to be printed after decimal point,
  468.          for x-axis values. Ignored for log. scales.
  469.                                                                Page 11
  470.  
  471. ndpy   = Number of decimal places to be printed after decimal point,
  472.          for y-axis values. Ignored for log. scales.
  473.  
  474. nparms = Number of parameters to be passed to function ifn.
  475.  
  476. npts   = Number of data points for this plot.
  477.          Set npts = 0 to plot a function curve,
  478.                   = -1 to indicate plotting a string of text.
  479.                   = -2 to indicate clearing an area of the graph.
  480.  
  481. nsdivx = Number of secondary divisions along x-axis (between main
  482.          divisions). Set nsdivx = 1 or 9 for log scales.
  483.  
  484. nsdivy = Number of secondary divisions along y-axis (between other
  485.          divisions). Set nsdivy = 1 or 9 for log scales.
  486.  
  487. nsets  = Number of sets of data to be plotted. A set of data is 
  488.          defined here as a string of text, a user-defined 
  489.          function, or a set of points.
  490.  
  491. p(i)   = Up to 20 parameters to be passed to function ifn. The 
  492.          maximum number of parameters can be changed by modifying 
  493.          the DIMENSION statement for P() in the main program 
  494.          segment.
  495.  
  496. strng  = A string of text to be printed on the graph.
  497.  
  498. x1,x2  = Start and end values of x for plotting function ifn.
  499.  
  500. xl     = Length of x-axis, cm.
  501.  
  502. xlabel = x-axis heading.
  503.  
  504. xmin,xmax = Minimum & maximum x values to define edges of plotting 
  505.             area.
  506.  
  507. yl     = Length of y-axis, cm.
  508.  
  509. ylabel = y-axis heading.
  510.  
  511. ymin,ymax = Minimum & maximum y values to define edges of plotting 
  512.             area.
  513.  
  514.                                                                Page 12
  515.  
  516. Appendix B.  Symbols and line types
  517. ====================================
  518.  
  519.  
  520.      When a set of data points is to be plotted, a symbol from 
  521.      Table B1 is plotted at the position of each point. When points 
  522.      are to be joined with lines, the type of line specified by 
  523.      ltyp is shown below in Table B2. The symbols and lines can 
  524.      best be seen by printing out the demonstration graph GRAPH.004 
  525.      (see sections 3 and 4 for how to do this).
  526.  
  527.  
  528.        Table B1 : Symbols           Table B2 : Line Types (approx)      
  529.       --------------------         --------------------------------
  530.         mark:-                       ltyp:-
  531.         1 = point                    1 =  continuous line
  532.         2 = open octagon             2 =  .................
  533.         3 = filled  "                3 =  . . . . . . . . .
  534.         4 = open square              4 =  - - - - - - - - -
  535.         5 = filled  "                5 =  -- . -- . -- . --
  536.         6 = open triangle
  537.         7 = filled  "
  538.         8 = cross
  539.         9 = plus
  540.        10 = star
  541.        11 = open diamond
  542.        12 = filled  "
  543.        32 to 126 = point plus ASCII character, defined below:
  544.  
  545.  
  546.  
  547.  
  548.         ASCII Characters
  549.        ==================
  550.  
  551.                     50  2       70  F       90  Z       110  n
  552.                     51  3       71  G       91  [       111  o
  553.         32          52  4       72  H       92  \       112  p
  554.         33  !       53  5       73  I       93  ]       113  q
  555.         34  "       54  6       74  J       94  ^       114  r
  556.         35  #       55  7       75  K       95  _       115  s
  557.         36  $       56  8       76  L       96  `       116  t
  558.         37  %       57  9       77  M       97  a       117  u
  559.         38  &       58  :       78  N       98  b       118  v
  560.         39  '       59  ;       79  O       99  c       119  w
  561.         40  (       60  <       80  P      100  d       120  x
  562.         41  )       61  =       81  Q      101  e       121  y
  563.         42  *       62  >       82  R      102  f       122  z
  564.         43  +       63  ?       83  S      103  g       123  {
  565.         44  ,       64  @       84  T      104  h       124  |
  566.         45  -       65  A       85  U      105  i       125  }
  567.         46  .       66  B       86  V      106  j       126  ~
  568.         47  /       67  C       87  W      107  k
  569.         48  0       68  D       88  X      108  l
  570.         49  1       69  E       89  Y      109  m
  571.                                                                Page 13
  572.  
  573. Appendix C.  Sample list of standard user-defined functions
  574. ============================================================
  575.  
  576.      You can plot any continuous function f(x) by calling one of 
  577.      the functions defined in FUNCTION FGRAPH(..., supplied on disk 
  578.      as file GRAPHFNS.for.  A number of standard functions have 
  579.      been supplied in this file to get you started. If you need any 
  580.      others, just program them in the same manner, and re-compile 
  581.      your program. The maximum number of parameters which can be 
  582.      passed is specified in the DIMENSION of the array P() in the 
  583.      main program segment (set at 20 in the sample main program 
  584.      GRAPH.for).
  585.  
  586.      The functions are called with a function number (to specify 
  587.      which function you want to evaluate), a list of parameters, 
  588.      and an x-value. It then returns the corresponding y-value. For 
  589.      example, if you want to plot the parabola  f(x) = 1.2 + 2*x - 
  590.      3.4*x^2,  you would specify :
  591.  
  592.        IFN  = 1      (function number 1 = polynomial)
  593.        P(1) = 2      (polynomial of order 2)
  594.        P(2) = 1.2    (1st coefficient of the polynomial)
  595.        P(3) = 2      (2nd     "      )
  596.        P(4) = 3.4    (3rd     "      )
  597.  
  598.      The file GRAPHFNS.for is printed out below for convenience. 
  599.      The standard functions available are :-
  600.  
  601. 1. Polynomial of any order   f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n 
  602.  
  603. 2. Exponential               f(x) = a + b.exp(c.x) 
  604.  
  605. 3. Power function            f(x) = a + b*x^c
  606.  
  607. 4. Logarithmic (natural)     f(x) = a + b.ln(c.x+d)
  608.  
  609. 5. Logarithmic (base 10)     f(x) = a + b.log(c.x+d)
  610.  
  611. 6. Inverse function          f(x) = a + b/(c+x)
  612.  
  613. 7. Circle (top or bottom half)
  614.  
  615. 8. Ellipse (top or bottom half)
  616.                                                                Page 14
  617.  
  618. This is a listing of the source code for the sample user-defined 
  619. functions supplied with the programs :-
  620.  
  621.  
  622.  
  623.       FUNCTION FGRAPH(IFN,P,X)
  624. * The list of functions for plotting on IGRAPH.
  625. * This list can be added to as required.
  626. *
  627. * FNUM = Function number
  628. * P    = Array of parameters to be passed to the selected function
  629. * X    = X-value at which the function is to be evaluated
  630. *
  631.       DIMENSION P(*)
  632. * To add more functions, add labels to the following statement:
  633.       GOTO (1,2,3,4,5,6,7,8) IFN 
  634. *
  635. * Function 1. Polynomial (to n-th order). n+2 parameters.
  636. *             P(1)=n,  P(2) to P(n+2) = coeffecients a0, a1, a2, ... an.
  637. *                      [ f(x) = a0 + a1.x + a2.x^2 + ... + an.x^n ]
  638. *
  639.    1  N = INT(P(1)+0.5)
  640.       POLY = P(N+2)
  641.       DO 100 I=N+1, 2, -1
  642.         POLY = X*POLY + P(I)
  643.  100  CONTINUE
  644.       FGRAPH = POLY
  645.       RETURN
  646. *
  647. *  Function 2. Exponential, 3 parameters.
  648. *              f(x) = a + b.exp(c.x)
  649. *
  650.    2  FGRAPH = P(1) + P(2)*EXP(P(3)*X)
  651.       RETURN
  652. *
  653. *  Function 3. Power function, 3 parameters.
  654. *              f(x) = a + b.x^c
  655. *
  656.    3  FGRAPH = P(1) + P(2)*X**P(3)
  657.       RETURN
  658. *
  659. *  Function 4. Logarithmic, 4 parameters.
  660. *              f(x) = a + b.ln(c.x+d)
  661. *
  662.    4  FGRAPH = P(1) + P(2)*ALOG(P(3)*X + P(4))
  663.       RETURN
  664. *
  665. *  Function 5. Base 10 Logarithmic, 4 parameters.
  666. *              f(x) = a + b.log(c.x+d)
  667. *
  668.    5  FGRAPH = P(1) + P(2)*ALOG10(P(3)*X + P(4))
  669.       RETURN
  670. *
  671. *  Function 6. Inverse function, 3 parameters.
  672. *              f(x) = a + b/(c+x)
  673.    6  FGRAPH = P(1) + P(2)/(P(3)+X)
  674.       RETURN
  675.                                                                Page 15
  676.  
  677. *
  678. *  Function 7. Circle.    4 Parameters.
  679. *              P(1) = 1 for top half of circle, -1 for bottom half.
  680. *              P(2) = radius.
  681. *              P(3) = x coordinate of centre of circle.
  682. *              P(4) = y coordinate of centre of circle.
  683. *
  684.    7  XXX = P(2)*P(2) - (X-P(3))**2.
  685.       IF(XXX.LT.0) XXX = 0.
  686.       FGRAPH = P(1)*SQRT(XXX) + P(4)
  687.       RETURN
  688. *
  689. *  Function 8. Ellipse.    5 Parameters.
  690. *              P(1) = 1 for top half of ellipse, -1 for bottom half.
  691. *              P(2) = max radius in x direction.
  692. *              P(3) = max radius in y direction.
  693. *              P(4) = x coordinate of centre of ellipse.
  694. *              P(5) = y coordinate of centre of ellipse.
  695. *
  696.    8  XXX = 1.- ((X-P(4))/P(2))**2.
  697.       IF(XXX.LT.0) XXX = 0.
  698.       FGRAPH = P(1)*P(3)*SQRT(XXX) + P(5)
  699.       RETURN
  700.       END
  701.  
  702. *---------------------------------------------------------------------------
  703.                                                                Page 16
  704.  
  705. Appendix D.  A sample data file for use with GRAPH
  706. ===================================================
  707.  
  708. Several demonstration graph files are supplied with the programs.
  709. The first one, GRAPH.001, is discussed in detail in this section
  710. to make it easier to understand how to set up your own graph data
  711. files for use with the sample main program GRAPH.for. The actual
  712. data file is :-
  713.  
  714. 1         16.       12.       Demonstration Graph 1
  715. 1         100       0.        10.
  716. 0         9         0         x-axis, log scale
  717. 10        4         0         y-axis, linear scale
  718. 1         2         5         2         5         1
  719. -2        1         0         0          {clear a box for legend table}
  720. 1.03      9.8       11.       8.2
  721. 6         -1        2         2         Data 1, fitted with spline
  722. 1.33      2.1
  723. 1.67      4.4
  724. 2.67      6.3
  725. 10.       7.4
  726. 30.       8.
  727. 60.       9.2
  728. 6         1         3         2         Data 2, with straight lines
  729. 3.        .3
  730. 8.        1.
  731. 15.       .5
  732. 25.       1.5
  733. 50.       1.5
  734. 90.       4.
  735. 6         0         6         3         Data 3, points only
  736. 2.        1.5
  737. 6.        2.
  738. 10.       2.6
  739. 20.       3.7
  740. 45.       5.5
  741. 80.       9.3
  742. 0         4         1         1         y = x/10 + 1.5
  743. 1         3         1.5       90.       {function 1. Polynomial}
  744. 1         1.5       0.1
  745.  
  746. The data file is described below on a line-by-line basis :
  747.  
  748. 1         16.       12.       Demonstration Graph 1
  749. --> igrprt=1, xl=16, yl=12, glabel='Demo....
  750. --> Print axes, x-axis 16 cm wide, y-axis 12 cm high, graph heading.
  751.  
  752. 1         100       0.        10.
  753. --> xmin=1, xmax=100, ymin=0, ymax=10
  754. --> x = 1 to 100,  y = 0 to 10.
  755.  
  756. 0         9         0         x-axis, log scale
  757. --> ndivx=0, nsdivx=9, ndpx=0, xlabel='x-axis....
  758. --> Log scale, 9 sub-divisions per decade, ignored, x-axis heading.
  759.  
  760. 10        4         0         y-axis, linear scale
  761. --> ndivy=10, nsdivy=4, ndpy=0, ylabel='y-axis....
  762. --> 10 labelled divisions, 4 subdivisions between each labelled division,
  763.     0 decimal places (ie print integers along y-axis), y-axis heading.
  764.                                                                Page 17
  765.  
  766. 1         2         5         2         5         1
  767. --> ivh=1, lohi=2, ioff=5, igrid=2, nsets=5, legpos=1
  768. --> vertical (portrait) format, Hi-res, Print 5 blank spaces (1/2") on
  769.     left of graph, line style 2 for the grid, 5 sets of data, legend table
  770.     in position 1 (top left).
  771.  
  772.     Now start the sets of data...
  773.     Data set number 1 =
  774.  
  775. -2        1         0         0          {clear a box for legend table}
  776. --> npts=-2, ltyp=1, (0,  0,  ignored)
  777. --> npts=-2 means clear a rectangular area. ltyp=1 means draw a box around
  778.     the cleared area in line style 1 (solid line)
  779.  
  780. 1.03      9.8       11.       8.2
  781. --> x1=1.03, y1=9.8, x2=11, y2=8.2
  782. --> Coordinates of top left and bottom right of box to be cleared.
  783.  
  784.     Data set number 2 =
  785.  
  786. 6         -1        2         2         Data 1, fitted with spline
  787. --> npts=6, ltyp=-1, mark=2, msize=2, legend='Data 1....
  788. --> 6 points for data set 1, join points with a cubic spline (smooth curve),
  789.     place symbol 2 at each point (open octagon), size 2 for the symbol,
  790.     description of data set 1 for the legend table.
  791.  
  792. 1.33      2.1
  793. 1.67      4.4
  794. 2.67      6.3
  795. 10.       7.4
  796. 30.       8.
  797. 60.       9.2
  798. --> The 6 data points for set 1 (x,y)
  799.  
  800.     Data set number 3 =
  801.  
  802. 6         1         3         2         Data 2, fitted with straight lines
  803. --> 6 points for data set 2, join points with straight lines, place
  804.     symbol 3 at each point (filled octagon), size 2 for the symbol,
  805.     description of data set 2 for the legend table.
  806.  
  807. 3.        .3
  808. 8.        1.
  809. 15.       .5
  810. 25.       1.5
  811. 50.       1.5
  812. 90.       4.
  813. --> the 6 data points for set 2 (x,y)
  814.  
  815.     Data set number 4 =
  816.  
  817. 6         0         6         3         Data 3
  818. --> 6 points for data set 3, plot points only (do not join), place symbol 6
  819.     at each point (open triangle), size 3 for the symbol, description of
  820.     data set 3 for the legend table.
  821.                                                                Page 18
  822.  
  823. 2.        1.5
  824. 6.        2.
  825. 10.       2.6
  826. 20.       3.7
  827. 45.       5.5
  828. 80.       9.3
  829. --> the 6 data points for set 3 (x,y)
  830.  
  831.     Data set number 5 =
  832.  
  833. 0         4         1         1         y = x/10 + 1.5
  834. --> npts=0, ltyp=4, mark=1, msize=1, legend='y = x/10....
  835. --> a user-defined function for set 4, line style 4 (dashed), ignored,
  836.     ignored, description of data set 4 for the legend table.
  837.  
  838. 1         3         1.5       90.       {function 1. Polynomial}
  839. --> ifn=1, nparms=3, x1=1.5, x2=90
  840. --> user-defined function number 1 = polynomial, 3 parameters to be passed,
  841.     plot from x=1.5 to x=90.
  842.  
  843. 1         1.5       0.1
  844. --> The 3 parameters (-->  y = 1 + 1.5*x + 0.1*x^2 )
  845. --> END OF FILE.
  846.