annotate scripts/plot/rose.m @ 14237:11949c9795a0

Revamp %!demos in m-files to use Octave coding conventions on spacing, etc. Add clf() to all demos using plot features to get reproducibility. Use 64 as input to all colormaps (jet (64)) to get reproducibility. * bicubic.m, cell2mat.m, celldisp.m, cplxpair.m, interp1.m, interp2.m, interpft.m, interpn.m, profile.m, profshow.m, convhull.m, delaunay.m, griddata.m, inpolygon.m, voronoi.m, autumn.m, bone.m, contrast.m, cool.m, copper.m, flag.m, gmap40.m, gray.m, hot.m, hsv.m, image.m, imshow.m, jet.m, ocean.m, pink.m, prism.m, rainbow.m, spring.m, summer.m, white.m, winter.m, condest.m, onenormest.m, axis.m, clabel.m, colorbar.m, comet.m, comet3.m, compass.m, contour.m, contour3.m, contourf.m, cylinder.m, daspect.m, ellipsoid.m, errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m, ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fill.m, fplot.m, grid.m, hold.m, isosurface.m, legend.m, loglog.m, loglogerr.m, pareto.m, patch.m, pbaspect.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m, plotyy.m, polar.m, quiver.m, quiver3.m, rectangle.m, refreshdata.m, ribbon.m, rose.m, scatter.m, scatter3.m, semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m, slice.m, sombrero.m, stairs.m, stem.m, stem3.m, subplot.m, surf.m, surfc.m, surfl.m, surfnorm.m, text.m, title.m, trimesh.m, triplot.m, trisurf.m, uigetdir.m, uigetfile.m, uimenu.m, uiputfile.m, waitbar.m, xlim.m, ylim.m, zlim.m, mkpp.m, pchip.m, polyaffine.m, spline.m, bicgstab.m, cgs.m, gplot.m, pcg.m, pcr.m, treeplot.m, strtok.m, demo.m, example.m, rundemos.m, speed.m, test.m, calendar.m, datestr.m, datetick.m, weekday.m: Revamp %!demos to use Octave coding conventions on spacing, etc.
author Rik <octave@nomad.inbox5.com>
date Fri, 20 Jan 2012 12:59:53 -0800
parents 72c96de7a403
children ce2b59a6d0e5
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: 14092
diff changeset
1 ## Copyright (C) 2007-2012 David Bateman
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
2 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
4 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
9 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
10 ## 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
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
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 ## 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
16 ## along with Octave; see the file COPYING. If not, see
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
18
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} rose (@var{th}, @var{r})
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
21 ## @deftypefnx {Function File} {} rose (@var{h}, @dots{})
7710
9a6012d7cbb7 Minor texinfo errors
David Bateman <dbateman@free.fr>
parents: 7322
diff changeset
22 ## @deftypefnx {Function File} {@var{h} =} rose (@dots{})
9a6012d7cbb7 Minor texinfo errors
David Bateman <dbateman@free.fr>
parents: 7322
diff changeset
23 ## @deftypefnx {Function File} {[@var{r}, @var{th}] =} rose (@dots{})
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
24 ##
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
25 ## Plot an angular histogram. With one vector argument @var{th}, plots the
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
26 ## histogram with 20 angular bins. If @var{th} is a matrix, then each column
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
27 ## of @var{th} produces a separate histogram.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
28 ##
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
29 ## If @var{r} is given and is a scalar, then the histogram is produced with
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
30 ## @var{r} bins. If @var{r} is a vector, then the center of each bin are
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
31 ## defined by the values of @var{r}.
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
32 ##
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
33 ## 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
34 ## line objects representing each histogram.
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
35 ##
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
36 ## If two output arguments are requested then, rather than plotting the
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
37 ## histogram, the polar vectors necessary to plot the histogram are
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
38 ## returned.
7710
9a6012d7cbb7 Minor texinfo errors
David Bateman <dbateman@free.fr>
parents: 7322
diff changeset
39 ##
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
40 ## @example
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
41 ## @group
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
42 ## [r, t] = rose ([2*randn(1e5,1), pi + 2 * randn(1e5,1)]);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
43 ## polar (r, t);
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
44 ## @end group
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
45 ## @end example
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
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 ## @seealso{polar, compass, hist}
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
48 ## @end deftypefn
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
49
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
50 function [thout, rout] = rose (varargin)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
51
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
52 [h, varargin, nargin] = __plt_get_axis_arg__ ((nargout > 1), "rose",
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 9245
diff changeset
53 varargin{:});
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
54
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
55 if (nargin < 1)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
56 print_usage ();
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
57 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
58
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
59 ## Force theta to [0,2*pi] range
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
60 th = varargin {1};
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
61 th = atan2 (sin (th), cos (th)) + pi;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
62
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
63 if (nargin > 1)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
64 x = varargin {2};
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
65 if (isscalar (x))
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
66 x = [0.5/x : 1/x : 1] * 2 * pi;
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
67 else
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
68 ## Force theta to [0,2*pi] range
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
69 x = atan2 (sin (x), cos (x)) + pi;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
70 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
71 else
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
72 x = [1/40 : 1/20 : 1] * 2 * pi;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
73 endif
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 [nn, xx] = hist (th, x);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
76 xx = xx(:).';
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
77 if (isvector (nn))
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
78 nn = nn (:);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
79 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
80 x1 = xx(1:end-1) + diff (xx, 1) / 2;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
81 x1 = [x1 ; x1; x1; x1](:);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
82 th = [0; 0; x1; 2*pi ; 2*pi];
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
83 r = zeros (4 * size (nn, 1), size (nn, 2));
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
84 r(2:4:end, :) = nn;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
85 r(3:4:end, :) = nn;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
86
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
87 if (nargout < 2)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
88 oldh = gca ();
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
89 unwind_protect
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
90 axes (h);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
91 newplot ();
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
92 hlist = polar (h, th, r);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
93 unwind_protect_cleanup
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
94 axes (oldh);
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
95 end_unwind_protect
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
96
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
97 if (nargout > 0)
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
98 thout = hlist;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
99 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
100 else
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
101 thout = th;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
102 rout = r;
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
103 endif
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
104
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
105 endfunction
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
106
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
107
7322
40a17a87155e [project @ 2007-12-18 21:32:10 by jwe]
jwe
parents:
diff changeset
108 %!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
109 %! clf;
11363
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
110 %! rose ([2*randn(1e5, 1), pi + 2*randn(1e5, 1)]);
a0dfd7e8e3e2 Assign data used in demo plots for reproducibility between runs
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
111