annotate scripts/plot/polar.m @ 17455:359366a4994f

waitbar.m: Use Octave coding conventions. * scripts/plot/waitbar.m: Rename 'retval' to 'h' to match documentation. Use 'hf', 'hp' for figure and patch graphics handles.
author Rik <rik@octave.org>
date Thu, 19 Sep 2013 14:26:47 -0700
parents 68bcac3c043a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14088
diff changeset
1 ## Copyright (C) 1993-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
18
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3063
diff changeset
19 ## -*- texinfo -*-
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} polar (@var{theta}, @var{rho})
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## @deftypefnx {Function File} {} polar (@var{theta}, @var{rho}, @var{fmt})
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
22 ## @deftypefnx {Function File} {} polar (@var{cplx})
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
23 ## @deftypefnx {Function File} {} polar (@var{cplx}, @var{fmt})
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
24 ## @deftypefnx {Function File} {} polar (@var{hax}, @dots{})
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
25 ## @deftypefnx {Function File} {@var{h} =} polar (@dots{})
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
26 ## Create a 2-D plot from polar coordinates @var{theta} and @var{rho}.
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
27 ##
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
28 ## If a single complex input @var{cplx} is given then the real part is used
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
29 ## for @var{theta} and the imaginary part is used for @var{rho}.
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
30 ##
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
31 ## The optional argument @var{fmt} specifies the line format in the same way
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
32 ## as @code{plot}.
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
33 ##
17126
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17072
diff changeset
34 ## If the first argument @var{hax} is an axes handle, then plot into this axis,
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17072
diff changeset
35 ## rather than the current axes returned by @code{gca}.
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
36 ##
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
37 ## The optional return value @var{h} is a graphics handle to the created plot.
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 12789
diff changeset
38 ##
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
39 ## @seealso{rose, compass, plot}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3063
diff changeset
40 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
41
2314
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
42 ## Author: jwe
949ab8eba8bc [project @ 1996-07-12 03:58:02 by jwe]
jwe
parents: 2313
diff changeset
43
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
44 function h = polar (varargin)
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
45
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
46 [hax, varargin, nargs] = __plt_get_axis_arg__ ("polar", varargin{:});
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
47
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
48 if (nargs < 1)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
49 print_usage ();
10730
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
50 endif
390d93e20531 Plot commands now print usage information without errors
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
51
17219
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17198
diff changeset
52 oldfig = [];
17309
68bcac3c043a Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents: 17219
diff changeset
53 if (! isempty (hax))
17219
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17198
diff changeset
54 oldfig = get (0, "currentfigure");
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17198
diff changeset
55 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
56 unwind_protect
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
57 hax = newplot (hax);
3063
4287b8c06fbf [project @ 1997-06-26 02:36:05 by jwe]
jwe
parents: 2847
diff changeset
58
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
59 if (nargs == 3)
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
60 if (! ischar (varargin{3}))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
61 error ("polar: FMT argument must be a string");
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
62 endif
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
63 htmp = __plr2__ (hax, varargin{:});
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
64 maxr = max (varargin{2}(:));
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
65 elseif (nargs == 2)
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
66 if (ischar (varargin{2}))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
67 htmp = __plr1__ (hax, varargin{:});
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
68 if (iscomplex (varargin{1}))
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
69 maxr = max (imag (varargin{1})(:));
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
70 else
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
71 maxr = max (varargin{1}(:));
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
72 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
73 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
74 fmt = "";
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
75 htmp = __plr2__ (hax, varargin{:}, fmt);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
76 maxr = max (varargin{2}(:));
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
77 endif
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
78 elseif (nargs == 1)
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
79 fmt = "";
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
80 htmp = __plr1__ (hax, varargin{:}, fmt);
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
81 if (iscomplex (varargin{1}))
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14846
diff changeset
82 maxr = max (imag (varargin{1})(:));
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
83 else
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 10226
diff changeset
84 maxr = max (varargin{1}(:));
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
85 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
86 else
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
87 print_usage ();
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
88 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
89
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
90 set (hax, "xlim", [-maxr, maxr], "ylim", [-maxr, maxr],
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
91 "xaxislocation", "zero", "yaxislocation", "zero",
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
92 "plotboxaspectratio", [1, 1, 1]);
7321
359f464342b3 [project @ 2007-12-18 03:48:03 by jwe]
jwe
parents: 7216
diff changeset
93
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
94 unwind_protect_cleanup
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
95 if (! isempty (oldfig))
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
96 set (0, "currentfigure", oldfig);
934
be867ddbe4aa [project @ 1994-11-17 04:23:41 by jwe]
jwe
parents: 904
diff changeset
97 endif
7207
71c03c7239fb [project @ 2007-11-28 02:19:25 by jwe]
jwe
parents: 7180
diff changeset
98 end_unwind_protect
6302
a5cd8b77e892 [project @ 2007-02-13 08:08:33 by jwe]
jwe
parents: 6257
diff changeset
99
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
100 if (nargout > 0)
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
101 h = htmp;
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
102 endif
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
103
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
104 endfunction
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
105
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
106 function retval = __plr1__ (h, theta, fmt)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
107
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
108 theta = theta(:);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
109 if (iscomplex (theta))
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
110 rho = imag (theta);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
111 theta = real (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
112 else
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
113 rho = theta;
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
114 theta = (1:rows (rho))';
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
115 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
116
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
117 retval = __plr2__ (h, theta, rho, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
118
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
119 endfunction
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
120
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
121 function retval = __plr2__ (h, theta, rho, fmt)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
122
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
123 if (ndims (theta) > 2 || ndims (rho) > 2)
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
124 error ("polar: THETA and RHO must be 2-D objects");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
125 endif
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
126 theta = real (theta);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
127 rho = real (rho);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
128
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
129 if (isscalar (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
130 if (isscalar (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
131 x = rho * cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
132 y = rho * sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
133 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
134 else
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
135 error ("polar: Can't plot constant THETA with varying RHO");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
136 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
137 elseif (isvector (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
138 if (isvector (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
139 if (length (theta) != length (rho))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
140 error ("polar: THETA and RHO vector lengths must match");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
141 endif
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
142 rho = rho(:);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
143 theta = theta(:);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
144 x = rho .* cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
145 y = rho .* sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
146 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
147 elseif (ismatrix (rho))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
148 theta = theta(:);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
149 t_nr = rows (theta);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
150 [r_nr, r_nc] = size (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
151 if (t_nr != r_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
152 rho = rho';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
153 r_nr = r_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
154 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
155 if (t_nr != r_nr)
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
156 error ("polar: THETA vector and RHO matrix sizes must match");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
157 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
158 x = diag (cos (theta)) * rho;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
159 y = diag (sin (theta)) * rho;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
160 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
161 else
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
162 error ("polar: invalid data for plotting");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
163 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
164 elseif (ismatrix (theta))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
165 if (isvector (rho))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
166 rho = rho(:);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
167 r_nr = rows (rho);
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
168 [t_nr, t_nc] = size (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
169 if (r_nr != t_nr)
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
170 theta = theta';
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
171 t_nr = t_nc;
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
172 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
173 if (r_nr != t_nr)
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
174 error ("polar: THETA matrix and RHO vector sizes must match");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
175 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
176 diag_r = diag (rho);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
177 x = diag_r * cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
178 y = diag_r * sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
179 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
180 elseif (ismatrix (rho))
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
181 if (! size_equal (rho, theta))
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
182 error ("polar: THETA and RHO matrix dimensions must match");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
183 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
184 x = rho .* cos (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
185 y = rho .* sin (theta);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
186 retval = __plt__ ("polar", h, x, y, fmt);
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
187 else
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
188 error ("polar: invalid data for plotting");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
189 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
190 else
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
191 error ("polar: invalid data for plotting");
9896
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
192 endif
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
193
1aeb39118764 convert some plot functions to subfunctions or make some them private
John W. Eaton <jwe@octave.org>
parents: 7321
diff changeset
194 endfunction
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
195
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
196
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
197 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
198 %! clf;
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
199 %! theta = linspace (0,2*pi,1000);
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
200 %! rho = sin (7*theta);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
201 %! polar (theta, rho);
17198
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
202 %! title ('polar() plot');
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
203
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
204 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
205 %! clf;
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
206 %! theta = linspace (0,2*pi,1000);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
207 %! cplx = theta + i*sin (7*theta);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
208 %! polar (cplx, 'g');
17198
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
209 %! title ('polar() plot of complex data');
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
210
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
211 %!demo
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
212 %! clf;
17198
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
213 %! theta = linspace (0,8*pi,1000);
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
214 %! rho = sin (5/4*theta);
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
215 %! polar (theta, rho);
17198
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
216 %! title ('polar() plot');
12789
482cc053281b codesprint: Add 2 demos for polar.m
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
217