home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / maths / plplot / plplot_2 / examples / f77 / x01f.f next >
Encoding:
Text File  |  1994-05-26  |  3.7 KB  |  172 lines

  1. ! $Id: x01f.f,v 1.2 1994/05/26 19:34:14 mjl Exp $
  2. ! $Log: x01f.f,v $
  3. ! Revision 1.2  1994/05/26  19:34:14  mjl
  4. ! Inserted missing CVS Id and Log fields for all Fortran demos.  Comment
  5. ! character changed to "!" everywhere, to work well with font-lock in Lucid
  6. ! emacs (requires a small change to fortran-mode.el).
  7. !
  8. !
  9.       program example01
  10. !     =================
  11. !
  12. ! Demonstration program for PLPLOT:
  13. !
  14. ! Plots three simple functions, each function occupies a separate page
  15.  
  16.     real x(101), y(101)
  17.     real xs(6), ys(6)
  18.     real    xscale, yscale, xoff, yoff
  19.         character*80 version
  20.     integer digmax
  21.     common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
  22.  
  23. ! Print plplot version
  24.  
  25.         call plgver(version)
  26.         write (6,*) 'Plplot version is ', version
  27.  
  28. ! Ask user to specify the output device
  29.  
  30.         call plssub(2,2)
  31.         call plinit()
  32.  
  33. ! Set up the data
  34. ! Original case
  35.  
  36.     xscale = 6.
  37.     yscale = 1.
  38.     xoff = 0.
  39.     yoff = 0.
  40.  
  41. ! Do a plot
  42.  
  43.     call plot1()
  44.  
  45. ! Set up the data
  46.  
  47.     xscale = 1.
  48.     yscale = 0.0014
  49.     yoff = 0.0185
  50.  
  51. ! Do a plot
  52.  
  53.     digmax = 5
  54.     call plsyax(digmax, 0)
  55.     call plot1()
  56.  
  57. !======================================================================
  58. !
  59. ! Set up the viewport and window using PLENV. The range in X is
  60. !  -2.0 to 10.0, and the range in Y is -0.4 to 2.0. The axes are
  61. !  scaled separately (just = 0), and we draw a box with axes 
  62. !  (axis = 1).
  63.  
  64.       call plcol(1)
  65.       call plenv(-2.0,10.0,-0.4,1.2,0,1)
  66.       call plcol(2)
  67.       call pllab('(x)','sin(x)/x','#frPLPLOT Example 1 - Sinc Function')
  68.  
  69. ! Fill up the arrays
  70.  
  71.       do 2 i = 1,100
  72.         x(i) = (i-20.0)/6.0
  73.         y(i) = 1.0
  74.         if (x(i).ne.0.0) y(i) = sin(x(i))/x(i)
  75.     2 continue
  76.  
  77. ! Draw the line
  78.  
  79.       call plcol(3)
  80.       call plline(100,x,y)
  81.  
  82. !======================================================================
  83. !
  84. ! For the final graph we wish to override the default tick intervals,
  85. !  and so do not use PLENV
  86.  
  87.       call pladv(0)
  88.  
  89. ! Use standard viewport, and define X range from 0 to 360 degrees,
  90. !  Y range from -1.2 to 1.2.
  91.  
  92.       call plvsta      
  93.       call plwind(0.0,360.0,-1.2,1.2)
  94.  
  95. ! Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
  96.  
  97.       call plcol(1)
  98.       call plbox('bcnst',60.0,2,'bcnstv',0.2,2)
  99.  
  100. ! Superimpose a dashed line grid, with 1.5 mm marks and spaces. With
  101. !  only a single mark and space element, we do not need arrays
  102.  
  103.       call plstyl(1,1500,1500)            
  104.       call plcol(2)
  105.       call plbox('g',30.0,0,'g',0.2,0)
  106.       call plstyl(0,0,0)
  107.  
  108.       call plcol(3)
  109.       call pllab('Angle (degrees)','sine',
  110.      *           '#frPLPLOT Example 1 - Sine function')
  111.  
  112.       do 3 i = 1,101
  113.         x(i) = 3.6 * (i-1)
  114.         y(i) = sin(x(i)*3.141592654/180.0)
  115.     3 continue
  116.  
  117.       call plcol(4)
  118.       call plline(101,x,y)
  119.  
  120. ! Don't forget to call PLEND to finish off!
  121.  
  122.       call plend
  123.  
  124.       end
  125.  
  126. !======================================================================
  127.  
  128.     subroutine plot1()
  129.  
  130.     real x(101), y(101)
  131.     real xs(6), ys(6)
  132.     real    xscale, yscale, xoff, yoff
  133.     common /plotdat/ x, y, xs, ys, xscale, yscale, xoff, yoff
  134.  
  135.     do 10 i = 1, 60
  136.         x(i)=xoff + xscale * float(i)/60.0
  137.         y(i)=yoff + yscale * x(i)**2
  138. 10    continue
  139.  
  140.     xmin = x(1)
  141.     xmax = x(60)
  142.     ymin = y(1)
  143.     ymax = y(60)
  144.  
  145.     do 20 i = 1, 6
  146.         xs(i) = x((i-1)*10+3)
  147.         ys(i) = y((i-1)*10+3)
  148. 20    continue
  149.  
  150. ! Set up the viewport and window using PLENV. The range in X is
  151. ! 0.0 to 6.0, and the range in Y is 0.0 to 30.0. The axes are
  152. ! scaled separately (just = 0), and we just draw a labelled
  153. ! box (axis = 0).
  154.  
  155.     call plcol(1)
  156.     call plenv(xmin, xmax, ymin, ymax, 0, 0)
  157.     call plcol(6)
  158.     call pllab("(x)","(y)","#frPLPLOT Example 1 - y=x#u2")
  159.  
  160. ! Plot the data points
  161.  
  162.     call plcol(9)
  163.     call plpoin(6,xs,ys,9)
  164.  
  165. ! Draw the line through the data
  166.  
  167.     call plcol(4)
  168.     call plline(60,x,y)
  169.  
  170.     return
  171.     end
  172.