7017
|
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2004, 2005, |
|
2 ## 2006, 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
245
|
19 |
3368
|
20 ## -*- texinfo -*- |
|
21 ## @deftypefn {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt}) |
7180
|
22 ## Make a two-dimensional plot given the polar coordinates @var{theta} and |
3368
|
23 ## @var{rho}. |
2311
|
24 ## |
|
25 ## The optional third argument specifies the line type. |
6895
|
26 ## @seealso{plot} |
3368
|
27 ## @end deftypefn |
4
|
28 |
2314
|
29 ## Author: jwe |
|
30 |
6302
|
31 function retval = polar (varargin) |
4
|
32 |
7321
|
33 [h, varargin, nargs] = __plt_get_axis_arg__ ("polar", varargin{:}); |
7216
|
34 |
7207
|
35 oldh = gca (); |
|
36 unwind_protect |
|
37 axes (h); |
|
38 newplot (); |
3063
|
39 |
7207
|
40 if (nargs == 3) |
|
41 if (! ischar (varargin{3})) |
|
42 error ("polar: third argument must be a string"); |
|
43 endif |
|
44 tmp = __plr2__ (h, varargin{:}); |
7321
|
45 maxr = max (varargin {2} (:)); |
|
46 elseif (nargs == 2) |
7207
|
47 if (ischar (varargin{2})) |
|
48 tmp = __plr1__ (h, varargin{:}); |
7321
|
49 if (iscomplex(varargin{1})) |
|
50 maxr = max (imag(varargin{1})(:)); |
|
51 else |
|
52 maxr = max (varargin{1}(:)); |
|
53 endif |
7207
|
54 else |
|
55 fmt = ""; |
|
56 tmp = __plr2__ (h, varargin{:}, fmt); |
7321
|
57 maxr = max (varargin {2} (:)); |
7207
|
58 endif |
7321
|
59 elseif (nargs == 1) |
7207
|
60 fmt = ""; |
|
61 tmp = __plr1__ (h, varargin{:}, fmt); |
7321
|
62 if (iscomplex(varargin{1})) |
|
63 maxr = max (imag(varargin{1})(:)); |
|
64 else |
|
65 maxr = max (varargin{1}(:)); |
|
66 endif |
7207
|
67 else |
|
68 print_usage (); |
934
|
69 endif |
7207
|
70 |
7321
|
71 set (h, "xlim", [-maxr, maxr], "ylim", [-maxr, maxr], |
|
72 "xaxislocation", "zero", "yaxislocation", "zero", |
|
73 "dataaspectratio", [1, 1, 1]); |
|
74 |
7207
|
75 if (nargout > 0) |
|
76 retval = tmp; |
934
|
77 endif |
7207
|
78 unwind_protect_cleanup |
|
79 axes (oldh); |
|
80 end_unwind_protect |
6302
|
81 |
4
|
82 endfunction |