annotate scripts/plot/draw/rose.m @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents bd51beb6205e
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 ## Copyright (C) 2007-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
7 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
8 ## This file is part of Octave.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
13 ## (at your option) any later version.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
14 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22636
diff changeset
18 ## GNU General Public License for more details.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
19 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
20 ## You should have received a copy of the GNU General Public License
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 24432
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
25
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
27 ## @deftypefn {} {} rose (@var{th})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
28 ## @deftypefnx {} {} rose (@var{th}, @var{nbins})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
29 ## @deftypefnx {} {} rose (@var{th}, @var{bins})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
30 ## @deftypefnx {} {} rose (@var{hax}, @dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
31 ## @deftypefnx {} {@var{h} =} rose (@dots{})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 19697
diff changeset
32 ## @deftypefnx {} {[@var{thout} @var{rout}] =} rose (@dots{})
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
33 ## Plot an angular histogram.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
34 ##
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
35 ## With one vector argument, @var{th}, plot the histogram with 20 angular bins.
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
36 ## If @var{th} is a matrix then each column of @var{th} produces a separate
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
37 ## histogram.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
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 ## If @var{nbins} is given and is a scalar, then the histogram is produced with
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
40 ## @var{nbin} bins. If @var{bins} is a vector, then the center of each bin is
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
41 ## defined by the values in @var{bins} and the number of bins is
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
42 ## given by the number of elements in @var{bins}.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
43 ##
24431
0c6cedafc71e doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents: 23219
diff changeset
44 ## If the first argument @var{hax} is an axes handle, then plot into this axes,
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17072
diff changeset
45 ## rather than the current axes returned by @code{gca}.
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17072
diff changeset
46 ##
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
47 ## The optional return value @var{h} is a vector of graphics handles to the
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
48 ## line objects representing each histogram.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
49 ##
19593
446c46af4b42 strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents: 17744
diff changeset
50 ## If two output arguments are requested then no plot is made and
16814
64e7bb01fce2 doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents: 14872
diff changeset
51 ## the polar vectors necessary to plot the histogram are returned instead.
7710
9a6012d7cbb7 Minor texinfo errors
David Bateman <dbateman@free.fr>
parents: 7322
diff changeset
52 ##
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
53 ## Example
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
54 ##
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
55 ## @example
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
56 ## @group
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
57 ## [th, r] = rose ([2*randn(1e5,1), pi + 2*randn(1e5,1)]);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
58 ## polar (th, r);
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
59 ## @end group
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
60 ## @end example
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
61 ##
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
62 ## Programming Note: When specifying bin centers with the @var{bins} input,
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
63 ## the edges for bins 2 to N-1 are spaced so that @code{@var{bins}(i)} is
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
64 ## centered between the edges. The final edge is drawn halfway between bin N
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
65 ## and bin 1. This guarantees that all input @var{th} will be placed into one
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
66 ## of the bins, but also means that for some combinations bin 1 and bin N may
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
67 ## not be centered on the user's given values.
17122
eaab03308c0b doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents: 17072
diff changeset
68 ## @seealso{hist, polar}
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
69 ## @end deftypefn
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
70
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
71 function [thout, rout] = rose (varargin)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
72
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
73 [hax, varargin, nargin] = __plt_get_axis_arg__ ("rose", varargin{:});
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
74
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
75 if (nargin < 1)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
76 print_usage ();
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
77 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
78
22403
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
79 th = varargin{1};
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
80 ## Force theta to [0,2*pi] range
22403
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
81 th = atan2 (sin (th), cos (th));
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
82 th(th < 0) += 2*pi;
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
83
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
84 custom_bins = false;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
85 if (nargin == 1)
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
86 bins = [1/40 : 1/20 : 1] * 2*pi;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
87 else
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
88 bins = varargin{2};
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
89 if (isscalar (bins))
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
90 bins = [0.5/bins : 1/bins : 1] * 2*pi;
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
91 else
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
92 custom_bins = true;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
93 ## Force angles to [0,2*pi] range
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
94 bins = atan2 (sin (bins), cos (bins));
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
95 bins(bins < 0) += 2*pi;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
96 bins = unique (bins);
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
97 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
98 endif
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
99 if (numel (bins) < 3)
22403
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
100 warning ("rose: bin sizes >= pi will not plot correctly");
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
101 endif
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
102
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
103 [counts, binctr] = hist (th, bins);
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
104 binctr = binctr(:).'; # Force row vector
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
105 if (isvector (counts))
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
106 counts = counts(:);
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
107 endif
22636
c44d57c0a925 maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents: 22539
diff changeset
108
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
109 binedge = binctr(1:end-1) + diff (binctr) / 2;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
110 binedge = [binedge ; zeros(size(binedge)); zeros(size(binedge)); binedge];
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
111 binedge = binedge(:);
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
112 if (! custom_bins)
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
113 ## Add in implicit edges at 0 and 2*pi
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
114 th = [0; 0; binedge; 2*pi ; 0];
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
115 else
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
116 ## Add in final edge
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
117 last_bin_edge = binctr(end) + diff ([binctr(end), (2*pi+binctr(1))])/2;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
118 if ((binedge(end) + last_bin_edge)/2 != binctr(end))
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
119 warning ("rose: bin 1 and bin %d are not centered", numel (binctr));
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
120 endif
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
121 th = [0; last_bin_edge; binedge; last_bin_edge; 0];
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
122 endif
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
123
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
124 r = zeros (4 * rows (counts), columns (counts));
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
125 r(2:4:end, :) = counts;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
126 r(3:4:end, :) = counts;
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
127
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
128 if (nargout < 2)
17476
f0f4b524b6d0 maint: Correct indentation for several plot routines.
Rik <rik@octave.org>
parents: 17301
diff changeset
129 oldfig = [];
f0f4b524b6d0 maint: Correct indentation for several plot routines.
Rik <rik@octave.org>
parents: 17301
diff changeset
130 if (! isempty (hax))
f0f4b524b6d0 maint: Correct indentation for several plot routines.
Rik <rik@octave.org>
parents: 17301
diff changeset
131 oldfig = get (0, "currentfigure");
f0f4b524b6d0 maint: Correct indentation for several plot routines.
Rik <rik@octave.org>
parents: 17301
diff changeset
132 endif
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
133 unwind_protect
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
134 hax = newplot (hax);
17126
26589abbc78d Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents: 17122
diff changeset
135 htmp = polar (th, r);
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
136 unwind_protect_cleanup
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
137 if (! isempty (oldfig))
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
138 set (0, "currentfigure", oldfig);
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
139 endif
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
140 end_unwind_protect
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
141
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
142 if (nargout > 0)
17072
22fa8c77b92d polar.m, rose.m: Overhaul to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 16814
diff changeset
143 thout = htmp;
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
144 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
145 else
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
146 thout = th;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
147 rout = r;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
148 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
149
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
150 endfunction
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
151
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
152
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
153 %!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
154 %! clf;
18924
9a5e03801d23 Update some plot %!demos so that they run under Matlab.
Rik <rik@octave.org>
parents: 17744
diff changeset
155 %! rose (2*randn (1e5, 1), 8);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 20852
diff changeset
156 %! title ("rose() angular histogram plot with 8 bins");
18924
9a5e03801d23 Update some plot %!demos so that they run under Matlab.
Rik <rik@octave.org>
parents: 17744
diff changeset
157
9a5e03801d23 Update some plot %!demos so that they run under Matlab.
Rik <rik@octave.org>
parents: 17744
diff changeset
158 %!demo
9a5e03801d23 Update some plot %!demos so that they run under Matlab.
Rik <rik@octave.org>
parents: 17744
diff changeset
159 %! clf;
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
160 %! rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]);
22302
1c4cd12987f5 Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents: 20852
diff changeset
161 %! title ("rose() angular histogram plot with 2 data series");
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
162
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
163 %!demo
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
164 %! clf;
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
165 %! rose ([0, 2, 3, 5], [0, pi/2, pi, 3*pi/2]);
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
166 %! title ("rose() angular histogram plot with specified bins");
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
167
22403
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
168 ## Test input validation
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
169 %!error rose ()
cc3be522ec79 rose.m: Fix plotting that was off by 180 degrees (bug #48889).
Rik <rik@octave.org>
parents: 22323
diff changeset
170 %!warning <bin sizes .= pi will not plot correctly>
22539
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
171 %! [th, r] = rose ([1 2 2 4 4 4], 2);
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
172 %!warning <bin 1 and bin 3 are not centered>
e9f77d099a63 rose: Fix behavior when bin centers are specified (bug #48889).
Rik <rik@octave.org>
parents: 22403
diff changeset
173 %! [th, r] = rose ([1 2 2 4 4 4], [1 2 3]);