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

  1.       PROGRAM GRAPH
  2. *
  3. * Fortran source GRAPH.for v2.0      Copyright (C) D.I.Hoyer, 1990
  4. *
  5.       INTEGER*2 IGRAPH
  6.       CHARACTER*80 GLABEL, XLABEL, YLABEL, LEGEND, STRNG
  7.       DIMENSION IGRAPH(1040,110), X(200), Y(200), P(20)
  8. *
  9. * Graph plotting on dot matrix printers. 
  10. *
  11. * This is a sample main program for plotting a graph from a data file,
  12. * which must be set up as described in the manual.
  13. *
  14. * The program is set up for IBM, Epson, Star type dot matrix printers.
  15. * If you have a printer which uses different graphics commands, or if
  16. * the graph doesn't appear to print properly, check your printer manual
  17. * and change the appropriate parameters in subroutine PRTGRF.
  18. *
  19. * Maximum graph size (nominal, for Hi-res plotting) = 20 x 25 cm.
  20. * This can be changed by changing the DIMENSION of IGRAPH :
  21. * DIMENSION IGRAPH(a,b) : a = max no. of dot columns across page
  22. *                         b = (max no of dot rows)/14 + 1
  23. *
  24. * GLABEL, XLABEL & YLABEL : Graph heading, and X & Y axis labels.
  25. * XL,YL  = Lengths of X and Y axes, cm.  
  26. * MAXX = Number of dots across x-axis. (calculated by PREP)
  27. * MAXY = Number of dots along y-axis.  (calculated by PREP)
  28. * XMIN, XMAX, YMIN, YMAX = Min & max x,y values to define edges of
  29. *                          plotting area.
  30. * XMINA, XMAX, YMINA, YMAXA = Total plotting area, including space above,
  31. *                             below and left of the graph for labels. These
  32. *                             are calculated by PREP
  33. * NDIVX, NDIVY   = No of divisions along axes (0 for log. scales)
  34. * NSDIVX, NSDIVY = No of secondary divisions along axes (between other 
  35. *                  divisions). Use 1 or 9 for log. scales.
  36. * NDPX, NDPY     = No of decimal places to be printed after dec. point, for
  37. *                  axis values. Ignored for log. scales.
  38. * IVH   = 1 for vertical (portrait) printout, 2 for horizontal (landscape).
  39. * IGRPRT= 1 to print the axes,
  40. *         0 to suppress printing of axes.
  41. * LOHI  = 1 for Low-res (quick) plot, 2 for Hi-Res.
  42. * IOFF  = Offset. This number of blank spaces will be printed from the left
  43. *                 margin ahead of the graph.
  44. * IGRID = 0 to print axes without grid lines, 
  45. *         1 to n for grid lines of line type LTYP.
  46. * NSETS = No of sets of data to be plotted.
  47. *         Each set of points, curve, function or text string is a data set.
  48. * LEGPOS= Position of legend block. 1 = top left, to 4 = top right.
  49. *                                   5 = bott. " , to 8 = bott. "  .
  50. * NPTS  = No of data points for current data set, or if <=0 then..
  51. *           0 to plot a function curve,
  52. *          -1 for plotting a text string,
  53. *          -2 to clear a rectangular area of the graph, with optional border.
  54. * LTYP  = Line type for joining points.
  55. *         0 = no line,
  56. *         1 to 5 straight lines,
  57. *         -5 to -1 for cubic spline fit (smooth curve).
  58. * MARK  = Symbol to be plotted at each point 
  59. *         (1 = dot, 2..8 = symbol, 32..126 = ASCII character)
  60. * MSIZE = Size of MARK (1..n) Try 3 for a start. 
  61. * LEGEND= Text to describe each data set. 
  62. *         Blank to suppress.
  63. * IFN   = Function number (pre-compiled in FUNCT) to plot if NPTS=0.
  64. * NPARMS= Number of parameters to be passed to function IFN (max 100).
  65. * X1,X2 = Start and end values of x for plotting IFN.
  66. * P(J),J=1,NPARMS = The parameters to be passed to function IFN.
  67. * ITXSIZ= Size of text to be plotted (1 to n).  2 = "normal".
  68. * STRNG = A string of text to be printed on the graph
  69. *
  70. * MMAXX,MMAXY are for passing the dimension of IGRAPH through subs. 
  71. *             (calculated by PREP)
  72. *             MMAXX is the number of columns of dots across the page,
  73. *             MMAXY is the (number of rows of dots)/14
  74. *
  75.       READ(5,606) IGRPRT, XL, YL, GLABEL
  76.  606  FORMAT(I10,2F10.0,A60)
  77.       READ(5,505) XMIN, XMAX, YMIN, YMAX
  78.  505  FORMAT(8F10.0)
  79.       READ(5,101) NDIVX, NSDIVX, NDPX, XLABEL
  80.  101  FORMAT(3I10,A60)
  81.       READ(5,101) NDIVY, NSDIVY, NDPY, YLABEL
  82.       READ(5,202) IVH, LOHI, IOFF, IGRID, NSETS, LEGPOS
  83.  202  FORMAT(8I10)
  84. *
  85. * Do some preparations/calcs before plotting axes or data
  86. *
  87.       CALL PREP(XL,YL,NDIVX,NDIVY,XMINA,XMAXA,YMINA,YMAXA,
  88.      $ XMIN,YMIN,XMAX,YMAX,MAXX,MAXY,MMAXX,MMAXY,LOHI,IVH)
  89. *
  90. * Clear the graph (this is only necessary if you want your program
  91. * to print more than one graph, as the first graph is clear when you start).
  92. * Remove the comment asterisk in column 1 to activate the next line if you
  93. * need to clear the graph: 
  94. *
  95. *     CALL CLRGRF(MMAXX,MMAXY,IGRAPH)
  96. *
  97. * Draw the axes
  98. *
  99.       IF(IGRPRT.EQ.1) CALL AXES(IGRID,NDIVX,NDIVY,NSDIVX,NSDIVY,NDPX,
  100.      $ NDPY,GLABEL,XLABEL,YLABEL,XMINA,XMAXA,YMINA,YMAXA,XMIN,YMIN,XMAX,
  101.      $ YMAX,MAXX,MAXY,MMAXX,MMAXY,LOHI,IGRAPH,IVH)
  102. *
  103. * Read the NSETS sets of data
  104. *
  105.       ILEGND = 0
  106.       DO 10 I=1, NSETS
  107.         READ(5,707) NPTS, LTYP, MARK, MSIZE, LEGEND
  108.  707    FORMAT(4I10,A)
  109.  
  110.         IF(NPTS.EQ.-2) THEN  ! If NPTS=-2 then clear a box, with border
  111.           READ(5,505) X(1), Y(1), X(2), Y(2)
  112.  
  113.         ELSEIF(NPTS.EQ.-1) THEN  ! If NPTS=-1 then text is to be plotted.
  114.           READ(5,808) IORI, ITXSIZ, XX, YY
  115.  808      FORMAT(2I10,2F10.0)
  116.           READ(5,909) STRNG
  117.  909      FORMAT(A)
  118.  
  119.         ELSEIF(NPTS.EQ.0) THEN  ! If NPTS=0 then a function plot is required.
  120.           READ(5,404) IFN, NPARMS, X1, X2
  121.  404      FORMAT(2I10,2F10.0)
  122.           READ(5,505) (P(J),J=1,NPARMS)
  123.  
  124.         ELSE  ! A set of points is to be plotted
  125.           READ(5,303) (X(J),Y(J),J=1,NPTS)
  126.  303      FORMAT(2F10.0)
  127.         ENDIF
  128. *-------Plot the data set (text, function or points)
  129.         CALL PLOTD(NPTS,LTYP,MARK,MSIZE,LEGEND,IORI,ITXSIZ,XX,YY,
  130.      $    XMINA,XMAXA,YMINA,YMAXA,XMIN,YMIN,XMAX,YMAX,MAXX,MAXY,MMAXX,
  131.      $    MMAXY,LOHI,IGRAPH,IVH,STRNG,IFN,X1,X2,P,X,Y,ILEGND,LEGPOS,
  132.      $    NDIVX,NDIVY)
  133.   10  CONTINUE
  134. *
  135. * Print out the graph
  136. *
  137.       CALL PRTGRF(IOFF,MMAXX,MMAXY,LOHI,IGRAPH)
  138.       STOP
  139.       END
  140.  
  141. *---------------------------------------------------------------------------
  142.  
  143.       INCLUDE "GRAPHFNS.for"
  144.       INCLUDE "GRAPHLIB.for"
  145.  
  146. *---------------------------------------------------------------------------