1! Pie chart demo. 2! 3! Copyright (C) 2004-2016 Alan W. Irwin 4! 5! This file is part of PLplot. 6! 7! PLplot is free software; you can redistribute it and/or modify 8! it under the terms of the GNU Library General Public License as 9! published by the Free Software Foundation; either version 2 of the 10! License, or (at your option) any later version. 11! 12! PLplot is distributed in the hope that it will be useful, 13! but WITHOUT ANY WARRANTY; without even the implied warranty of 14! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15! GNU Library General Public License for more details. 16! 17! You should have received a copy of the GNU Library General Public 18! License along with PLplot; if not, write to the Free Software 19! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 21! N.B. the pl_test_flt parameter used in this code is only 22! provided by the plplot module to allow convenient developer 23! testing of either kind(1.0) or kind(1.0d0) floating-point 24! precision regardless of the floating-point precision of the 25! PLplot C libraries. We do not guarantee the value of this test 26! parameter so it should not be used by users, and instead user 27! code should replace the pl_test_flt parameter by whatever 28! kind(1.0) or kind(1.0d0) precision is most convenient for them. 29! For further details on floating-point precision issues please 30! consult README_precision in this directory. 31! 32program x13f 33 use plplot, double_PI => PL_PI 34 implicit none 35 real(kind=pl_test_flt), parameter :: PI = double_PI 36 real(kind=pl_test_flt) :: just, dx, dy, x(500), y(500) 37 integer :: i, j, dthet, theta0, theta1, theta 38 integer :: plparseopts_rc 39 character(len=20), dimension(5) :: text = & 40 (/ 'Maurice ', 'Geoffrey', 'Alan ', 'Rafael ', 'Vince '/) 41 real(kind=pl_test_flt) :: per(5) = & 42 (/ 10._pl_test_flt , 32._pl_test_flt , 12._pl_test_flt , 30._pl_test_flt , 16._pl_test_flt /) 43 44 ! Process command-line arguments 45 plparseopts_rc = plparseopts(PL_PARSE_FULL) 46 if(plparseopts_rc .ne. 0) stop "plparseopts error" 47 48 ! Ask user to specify the output device. 49 call plinit() 50 51 call pladv(0) 52 ! Ensure window has aspect ratio of one so circle is 53 ! plotted as a circle. 54 call plvasp(1.0_pl_test_flt) 55 call plwind(0._pl_test_flt, 10._pl_test_flt, 0._pl_test_flt, 10._pl_test_flt) 56 ! call plenv( 0._pl_test_flt, 10._pl_test_flt, 0._pl_test_flt, 10._pl_test_flt, 1, -2 ) 57 call plcol0(2) 58 59 ! n.b. all theta quantities scaled by 2*pi/500 to be integers to avoid 60 ! floating point logic problems. 61 theta0 = 0 62 dthet = 1 63 64 do i = 0, 4 65 j = 0 66 x(j+1) = 5._pl_test_flt 67 y(j+1) = 5._pl_test_flt 68 j = j + 1 69 ! n.b. the theta quantities multiplied by 2*pi/500 afterward so 70 ! in fact per is interpreted as a percentage. 71 theta1 = int(theta0 + 5*per(i+1)) 72 if (i .eq. 4) theta1 = 500 73 do theta = theta0, theta1, dthet 74 x(j+1) = 5 + 3*cos((2._pl_test_flt*pi/500._pl_test_flt)*theta) 75 y(j+1) = 5 + 3*sin((2._pl_test_flt*pi/500._pl_test_flt)*theta) 76 j = j + 1 77 enddo 78 79 call plcol0(i+1) 80 call plpsty( mod(i+3, 8) + 1 ) 81 call plfill(x(:j), y(:j)) 82 call plcol0(1) 83 call plline(x(:j), y(:j)) 84 85 just = (2._pl_test_flt*pi/500._pl_test_flt)*(theta0 + theta1) / 2._pl_test_flt 86 dx = 0.25_pl_test_flt * cos(just) 87 dy = 0.25_pl_test_flt * sin(just) 88 if ((theta0 + theta1) .lt. 250 .or. & 89 (theta0 + theta1) .gt. 750) then 90 just = 0._pl_test_flt 91 else 92 just = 1._pl_test_flt 93 endif 94 call plptex( x(j/2+1)+dx, y(j/2+1)+dy, 1._pl_test_flt, 0._pl_test_flt, just, text(i+1) ) 95 theta0 = theta - dthet 96 enddo 97 98 call plfont(2) 99 call plschr( 0._pl_test_flt, 1.3_pl_test_flt) 100 call plptex( 5._pl_test_flt, 9._pl_test_flt, 1._pl_test_flt, 0._pl_test_flt, 0.5_pl_test_flt, 'Percentage of Sales' ) 101 102 call plend 103end program x13f 104