Mercurial > hg > octave-lyh
annotate scripts/plot/pie.m @ 11523:fd0a3ac60b0e
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 14 Jan 2011 05:47:45 -0500 |
parents | 3c7ba1e3dc21 |
children | c792872f8942 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 David Bateman |
7118 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
11341
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
20 ## @deftypefn {Function File} {} pie (@var{x}) |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
21 ## @deftypefnx {Function File} {} pie (@var{x}, @var{explode}) |
7118 | 22 ## @deftypefnx {Function File} {} pie (@dots{}, @var{labels}) |
23 ## @deftypefnx {Function File} {} pie (@var{h}, @dots{}); | |
24 ## @deftypefnx {Function File} {@var{h} =} pie (@dots{}); | |
25 ## Produce a pie chart. | |
26 ## | |
8325
b93ac0586e4b
spelling corrections
Brian Gough<bjg@network-theory.co.uk>
parents:
7313
diff
changeset
|
27 ## Called with a single vector argument, produces a pie chart of the |
7118 | 28 ## elements in @var{x}, with the size of the slice determined by percentage |
29 ## size of the values of @var{x}. | |
30 ## | |
31 ## The variable @var{explode} is a vector of the same length as @var{x} that | |
32 ## if non zero 'explodes' the slice from the pie chart. | |
33 ## | |
34 ## If given @var{labels} is a cell array of strings of the same length as | |
35 ## @var{x}, giving the labels of each of the slices of the pie chart. | |
36 ## | |
37 ## The optional return value @var{h} provides a handle to the patch object. | |
38 ## | |
11330 | 39 ## @seealso{pie3, bar, stem} |
7118 | 40 ## @end deftypefn |
41 | |
42 ## Very roughly based on pie.m from octave-forge whose author was | |
43 ## Daniel Heiserer <Daniel.heiserer@physik.tu-muenchen.de> | |
44 | |
45 function retval = pie (varargin) | |
46 | |
7215 | 47 [h, varargin] = __plt_get_axis_arg__ ("pie", varargin{:}); |
48 | |
7118 | 49 if (nargin < 1) |
50 print_usage (); | |
7215 | 51 else |
7118 | 52 oldh = gca (); |
53 unwind_protect | |
54 axes (h); | |
55 newplot (); | |
11330 | 56 tmp = __pie__ ("pie", h, varargin{:}); |
7118 | 57 unwind_protect_cleanup |
58 axes (oldh); | |
59 end_unwind_protect | |
60 endif | |
61 | |
62 if (nargout > 0) | |
63 retval = tmp; | |
64 endif | |
7119 | 65 |
7118 | 66 endfunction |
67 | |
7120 | 68 %!demo |
69 %! pie ([3, 2, 1], [0, 0, 1]); | |
70 %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); | |
71 | |
72 %!demo | |
73 %! pie ([3, 2, 1], [0, 0, 1], {"Cheddar", "Swiss", "Camembert"}); | |
74 %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); | |
75 %! axis ([-2,2,-2,2]); | |
11341
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
76 |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
77 %!demo |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
78 %! pie ([0.17, 0.34, 0.41], {"Cheddar", "Swiss", "Camembert"}); |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
79 %! colormap([1,0,0;0,1,0;0,0,1;1,1,0;1,0,1;0,1,1]); |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
80 %! axis ([-2,2,-2,2]); |
3c7ba1e3dc21
Add missing option slice for pie and pie3
Kai Habel <kai.habel@gmx.de>
parents:
11330
diff
changeset
|
81 %! title ("missing slice"); |