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

  1. ! $Id: x03f.f,v 1.2 1994/05/26 19:34:16 mjl Exp $
  2. ! $Log: x03f.f,v $
  3. ! Revision 1.2  1994/05/26  19:34:16  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 example03
  10. !     =================
  11. !
  12. ! Illustration of 1-1 scaling for polar plot
  13.  
  14.       character*3 text
  15.       real x0(0:360), y0(0:360)
  16.       real x(0:360), y(0:360)
  17.  
  18.       dtr = 3.141592654/180.0
  19.       do 1 i=0,360
  20.         x0(i) = cos(dtr * real(i))
  21.         y0(i) = sin(dtr * real(i))
  22.     1 continue
  23.  
  24. ! Ask user to specify the output device.
  25.  
  26.       call plinit()
  27.  
  28. ! Set up viewport and window, but do not draw box
  29.  
  30.       call plenv(-1.3,1.3,-1.3,1.3,1,-2)
  31.       do 2 i = 1,10
  32.         do 3 j = 0,360
  33.           x(j) = 0.1*i*x0(j)
  34.           y(j) = 0.1*i*y0(j)
  35.     3   continue
  36.  
  37. ! Draw circles for polar grid
  38.  
  39.         call plline(361,x,y)
  40.     2 continue
  41.  
  42.       call plcol(2)
  43.       do 4 i = 0,11
  44.         theta = 30.0*i
  45.         dx = cos(dtr*theta)
  46.         dy = sin(dtr*theta)
  47.  
  48. ! Draw radial spokes for polar grid
  49.  
  50.         call pljoin(0.0,0.0,dx,dy)
  51.         write (text,'(i3)') nint(theta)
  52.  
  53. ! Write labels for angle
  54.  
  55.         text = text(nsp(text):)
  56.         if (dx.ge.0) then
  57.           call plptex(dx,dy,dx,dy,-0.15,text)
  58.         else
  59.           call plptex(dx,dy,-dx,-dy,1.15,text)
  60.         end if
  61.     4 continue
  62.  
  63. ! Draw the graph
  64.  
  65.       do 5 i=0,360
  66.         r = sin(dtr*real(5*i))
  67.         x(i) = x0(i) * r
  68.         y(i) = y0(i) * r
  69.     5 continue
  70.       call plcol(3)
  71.       call plline(361,x,y)
  72.  
  73.       call plcol(4)
  74.       call plmtex
  75.      *   ('t',2.0,0.5,0.5,'#frPLPLOT Example 3 - r(#gh)=sin 5#gh')
  76.  
  77. ! Close the plot at end
  78.  
  79.       call plend
  80.       end
  81.  
  82.       function nsp(text)
  83. !     ==================
  84.  
  85. ! Find first non-space character
  86.  
  87.       character*(*) text
  88.  
  89.       l = len(text)
  90.       nsp = 1
  91.     1 if (text(nsp:nsp).eq.' ' .and. nsp.lt.l) then
  92.         nsp = nsp+1
  93.         goto 1
  94.       end if
  95.       end
  96.