File: x03f.fm4

package info (click to toggle)
plplot 5.9.9-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 84,772 kB
  • sloc: ansic: 86,290; xml: 26,754; ada: 17,685; cpp: 15,530; php: 11,938; tcl: 11,125; ml: 6,825; perl: 6,736; f90: 6,709; python: 6,237; java: 6,215; sh: 2,042; makefile: 192; lisp: 75; fortran: 64; sed: 52
file content (120 lines) | stat: -rw-r--r-- 3,233 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
c      $Id: x03f.fm4 11680 2011-03-27 17:57:51Z airwin $
c      Generates polar plot with, 1-1 scaling
c
c      Copyright (C) 2004  Alan W. Irwin
c
c      This file is part of PLplot.
c
c      PLplot is free software; you can redistribute it and/or modify
c      it under the terms of the GNU Library General Public License as
c      published by the Free Software Foundation; either version 2 of the
c      License, or (at your option) any later version.
c
c      PLplot is distributed in the hope that it will be useful,
c      but WITHOUT ANY WARRANTY; without even the implied warranty of
c      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c      GNU Library General Public License for more details.
c
c      You should have received a copy of the GNU Library General Public
c      License along with PLplot; if not, write to the Free Software
c      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

      implicit none
      include 'plplot_parameters.h'

      character*3 text
      real*8 x0(0:360), y0(0:360)
      real*8 x(0:360), y(0:360), dtr, theta, dx, dy, r, offset
      integer i, j, nsp
c      Process command-line arguments
      call plparseopts(PL_PARSE_FULL)

c     Set orientation to portrait - note not all device drivers
c     support this, in particular most interactive drivers do not.
      call plsori(1)

      dtr = PI/180.0d0
      do i=0,360
        x0(i) = cos(dtr * dble (i))
        y0(i) = sin(dtr * dble (i))
      enddo

c      Initialize PLplot

      call plinit()

c      Set up viewport and window, but do not draw box

      call plenv(-1.3d0, 1.3d0, -1.3d0, 1.3d0, 1, -2)

c     Draw circles for polar grid
      do i = 1,10
         call plarc(0.0d0, 0.0d0, 0.1d0*i, 0.1d0*i,
     &     0.0d0, 360.0d0, 0.0d0, 0)
      enddo

      call plcol0(2)
      do i = 0,11
        theta = 30.0d0*i
        dx = cos(dtr*theta)
        dy = sin(dtr*theta)

c        Draw radial spokes for polar grid

        call pljoin(0.0d0, 0.0d0, dx, dy)
        write (text,'(i3)') nint(theta)

c        Write labels for angle

        text = text(nsp(text):)

        if (theta .lt. 9.99) then
           offset = 0.45
        elseif (theta .lt. 99.9) then
	   offset = 0.30
        else
           offset = 0.15
        endif

c        Slightly off zero to avoid floating point logic flips at
c        90 and 270 deg.
        if (dx.ge.-0.00001d0) then
          call plptex(dx, dy, dx, dy, -offset, text)
        else
          call plptex(dx, dy, -dx, -dy, (1.d0 + offset), text)
        end if
      enddo
c      Draw the graph

      do i=0,360
        r = sin(dtr*dble (5*i))
        x(i) = x0(i) * r
        y(i) = y0(i) * r
      enddo
      call plcol0(3)
      call plline(361,x,y)

      call plcol0(4)
      call plmtex('t', 2.0d0, 0.5d0, 0.5d0,
     &  '#frPLplot Example 3 - r(#gh)=sin 5#gh')

c      Close the plot at end

      call plend
      end

      integer function nsp(text)
c      ==================

c      Find first non-space character
      implicit none

      character*(*) text
      integer l, len

      l = len(text)
      nsp = 1
      do while(text(nsp:nsp).eq.' ' .and. nsp.lt.l)
        nsp = nsp+1
      enddo
      end