1## Copyright (C) 1998, 1999, 2000  Joao Cardoso
2## Copyright (C) 2004  Rafael Laboissiere
3##
4## This program is free software; you can redistribute it and/or modify it
5## under the terms of the GNU General Public License as published by the
6## Free Software Foundation; either version 2 of the License, or (at your
7## option) any later version.
8##
9## This program is distributed in the hope that it will be useful, but
10## WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12## General Public License for more details.
13##
14## This file is part of plplot_octave.
15## It is based on the corresponding demo function of PLplot.
16## Does a simple pie chart.
17
18function x13c
19
20  text =[
21	 "Maurice",
22	 "Geoffrey",
23	 "Alan",
24	 "Rafael",
25	 "Vince"
26	 ];
27
28  per(1) = 10.;
29  per(2) = 32.;
30  per(3) = 12.;
31  per(4) = 30.;
32  per(5) = 16.;
33
34  ## Parse and process command line arguments */
35
36  ## (void) plparseopts(&argc, argv, PL_PARSE_FULL);
37
38  ## Initialize plplot */
39  plinit();
40
41  pladv(0);
42  ## Ensure window has aspect ratio of one so circle is
43  ## plotted as a circle. */
44  plvasp(1.0);
45  plwind(0., 10., 0., 10.);
46  ##plenv(0., 10., 0., 10., 1, -2);
47  plcol0(2);
48
49  theta0 = 0.;
50  dthet = 2 * pi / 500;
51  for i=0:4
52    x = [];
53    y = [];
54    j = 0;
55    x(j+1) = 5.;
56    y(j+1) = 5.;
57    j=j+1;
58    theta1 = theta0 + 2 * pi * per(i+1) / 100.;
59    if (i == 4)
60      theta1 = 2 * pi;
61    endif
62    for theta = theta0:dthet:theta1
63      x(j+1) = 5 + 3 * cos(theta);
64      y(j+1) = 5 + 3 * sin(theta);
65      j=j+1;
66    endfor
67    plcol0(i+1);
68    plpsty(rem((i + 3), 8) + 1);
69    plfill(x', y');
70    plcol0(1);
71    plline(x', y');
72    just = (theta0 + theta1) / 2.;
73    dx = .25 * cos(just); dy = .25 * sin(just);
74    if ((just < pi / 2) || (just > 3 * pi / 2) )
75      just = 0.;
76    else
77      just = 1.;
78    endif
79    plptex((x((j / 2) +1) + dx), (y((j / 2) +1) + dy), 1.0, 0.0, just, deblank(text(i+1,:)));
80    theta0 = theta1;
81  endfor
82  plfont(2);
83  plschr(0., 1.3);
84  plptex(5.0, 9.0, 1.0, 0.0, 0.5, "Percentage of Sales");
85  plend1();
86endfunction
87