Mercurial > hg > octave-nkf
annotate scripts/plot/view.m @ 17122:eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
* doc/interpreter/plot.txi: Add @findex entries that were in xlim.m
* scripts/miscellaneous/getappdata.m scripts/miscellaneous/setappdata.m,
scripts/plot/allchild.m, scripts/plot/ancestor.m, scripts/plot/area.m,
scripts/plot/axes.m, scripts/plot/axis.m, scripts/plot/bar.m,
scripts/plot/barh.m, scripts/plot/box.m, scripts/plot/caxis.m,
scripts/plot/cla.m, scripts/plot/clabel.m, scripts/plot/clf.m,
scripts/plot/close.m, scripts/plot/closereq.m, scripts/plot/colorbar.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourc.m,
scripts/plot/contourf.m, scripts/plot/copyobj.m, scripts/plot/cylinder.m,
scripts/plot/daspect.m, scripts/plot/diffuse.m, scripts/plot/ellipsoid.m,
scripts/plot/errorbar.m, scripts/plot/ezcontour.m, scripts/plot/ezcontourf.m,
scripts/plot/ezmesh.m, scripts/plot/ezmeshc.m, scripts/plot/ezplot.m,
scripts/plot/ezplot3.m, scripts/plot/ezpolar.m, scripts/plot/ezsurf.m,
scripts/plot/ezsurfc.m, scripts/plot/feather.m, scripts/plot/figure.m,
scripts/plot/fill.m, scripts/plot/findall.m, scripts/plot/findobj.m,
scripts/plot/fplot.m, scripts/plot/gca.m, scripts/plot/gcbf.m,
scripts/plot/gcbo.m, scripts/plot/gcf.m, scripts/plot/gco.m,
scripts/plot/ginput.m, scripts/plot/graphics_toolkit.m, scripts/plot/grid.m,
scripts/plot/gtext.m, scripts/plot/guidata.m, scripts/plot/guihandles.m,
scripts/plot/hdl2struct.m, scripts/plot/hggroup.m, scripts/plot/hidden.m,
scripts/plot/hist.m, scripts/plot/hold.m, scripts/plot/ishghandle.m,
scripts/plot/ishold.m, scripts/plot/isocolors.m, scripts/plot/isprop.m,
scripts/plot/legend.m, scripts/plot/line.m, scripts/plot/linkprop.m,
scripts/plot/loglog.m, scripts/plot/loglogerr.m, scripts/plot/mesh.m,
scripts/plot/meshc.m, scripts/plot/meshgrid.m, scripts/plot/meshz.m,
scripts/plot/newplot.m, scripts/plot/orient.m, scripts/plot/pareto.m,
scripts/plot/patch.m, scripts/plot/pcolor.m, scripts/plot/peaks.m,
scripts/plot/pie.m, scripts/plot/pie3.m, scripts/plot/plot.m,
scripts/plot/plot3.m, scripts/plot/plotmatrix.m, scripts/plot/plotyy.m,
scripts/plot/polar.m, scripts/plot/print.m, scripts/plot/quiver.m,
scripts/plot/quiver3.m, scripts/plot/rectangle.m, scripts/plot/refresh.m,
scripts/plot/refreshdata.m, scripts/plot/ribbon.m, scripts/plot/rose.m,
scripts/plot/saveas.m, scripts/plot/scatter.m, scripts/plot/scatter3.m,
scripts/plot/semilogx.m, scripts/plot/semilogxerr.m, scripts/plot/semilogy.m,
scripts/plot/semilogyerr.m, scripts/plot/shading.m, scripts/plot/shg.m,
scripts/plot/shrinkfaces.m, scripts/plot/slice.m, scripts/plot/specular.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/stem.m,
scripts/plot/stem3.m, scripts/plot/struct2hdl.m, scripts/plot/subplot.m,
scripts/plot/surf.m, scripts/plot/surface.m, scripts/plot/surfc.m,
scripts/plot/surfl.m, scripts/plot/tetramesh.m, scripts/plot/text.m,
scripts/plot/title.m, scripts/plot/trimesh.m, scripts/plot/triplot.m,
scripts/plot/trisurf.m, scripts/plot/view.m, scripts/plot/waitbar.m,
scripts/plot/waitforbuttonpress.m, scripts/plot/waterfall.m,
scripts/plot/whitebg.m, scripts/plot/xlabel.m, scripts/plot/xlim.m,
scripts/plot/ylabel.m, scripts/plot/ylim.m, scripts/plot/zlabel.m,
scripts/plot/zlim.m: Rewrite docstrings for most plot functions.
Emphasize clarity, use common "voice", and increase density of seealso links.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 31 Jul 2013 13:53:30 -0700 |
parents | df643a532b61 |
children | b5d6314314fc |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13141
diff
changeset
|
1 ## Copyright (C) 2007-2012 John W. Eaton |
6257 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6257 | 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 | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6257 | 18 |
19 ## -*- texinfo -*- | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
20 ## @deftypefn {Function File} {} view (@var{azimuth}, @var{elevation}) |
12642
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
21 ## @deftypefnx {Function File} {} view ([@var{azimuth} @var{elevation}]) |
f96b9b9f141b
doc: Periodic grammarcheck and spellcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
12575
diff
changeset
|
22 ## @deftypefnx {Function File} {} view ([@var{x} @var{y} @var{z}]) |
16356 | 23 ## @deftypefnx {Function File} {} view (2) |
24 ## @deftypefnx {Function File} {} view (3) | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
25 ## @deftypefnx {Function File} {} view (@var{hax}, @dots{}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
26 ## @deftypefnx {Function File} {[@var{azimuth}, @var{elevation}] =} view () |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
27 ## Query or set the viewpoint for the current axes. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
28 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
29 ## The parameters @var{azimuth} and @var{elevation} can be given as two |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
30 ## arguments or as 2-element vector. The viewpoint can also be specified with |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
31 ## Cartesian coordinates @var{x}, @var{y}, and @var{z}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
32 ## |
11344 | 33 ## The call @code{view (2)} sets the viewpoint to @var{azimuth} = 0 |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
34 ## and @var{elevation} = 90, which is the default for 2-D graphs. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
35 ## |
11344 | 36 ## The call @code{view (3)} sets the viewpoint to @var{azimuth} = -37.5 |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
37 ## and @var{elevation} = 30, which is the default for 3-D graphs. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
38 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
39 ## If the first argument @var{hax} is an axes handle, then operate on |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
40 ## this axis rather than the current axes returned by @code{gca}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
41 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
16356
diff
changeset
|
42 ## If no inputs are given, return the current @var{azimuth} and @var{elevation}. |
6257 | 43 ## @end deftypefn |
44 | |
45 ## Author: jwe | |
46 | |
11344 | 47 function [azimuth, elevation] = view (varargin) |
6257 | 48 |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
49 if (nargin < 4) |
7712
a626db2e8a1c
view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents:
7016
diff
changeset
|
50 if (nargin == 0) |
11391
98d523608f70
view.m: Return azimuth and elevation for nargin == 0.
Ben Abbott <bpabbott@mac.com>
parents:
11345
diff
changeset
|
51 args = {get(gca (), "view")}; |
11344 | 52 else |
53 ax = varargin{1}; | |
54 if (ishandle (ax) && strcmp (get (ax, "type"), "axes")) | |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
55 args = varargin(2:end); |
11344 | 56 else |
57 ax = gca; | |
58 args = varargin; | |
59 endif | |
60 endif | |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
61 if (length (args) == 1) |
11344 | 62 x = args{1}; |
63 if (length (x) == 2) | |
64 az = x(1); | |
65 el = x(2); | |
66 elseif (length (x) == 3) | |
67 [az, el] = cart2sph (x(1), x(2), x(3)); | |
68 az *= 180/pi; | |
69 az += 90; | |
70 el *= 180/pi; | |
71 elseif (x == 2) | |
10549 | 72 az = 0; |
73 el = 90; | |
6257 | 74 elseif (x == 3) |
10549 | 75 az = -37.5; |
76 el = 30; | |
6257 | 77 else |
11344 | 78 print_usage (); |
6257 | 79 endif |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
80 elseif (length (args) == 2) |
11344 | 81 az = args{1}; |
82 el = args{2}; | |
6257 | 83 endif |
84 | |
85 if (nargin > 0) | |
11344 | 86 set (ax, "view", [az, el]); |
6257 | 87 endif |
88 | |
89 if (nargout == 1) | |
90 error ("view: T = view () not implemented"); | |
91 endif | |
92 | |
93 if (nargout == 2) | |
94 azimuth = az; | |
95 elevation = el; | |
96 endif | |
97 else | |
98 print_usage (); | |
99 endif | |
100 | |
101 endfunction | |
13096 | 102 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
103 |
13096 | 104 %!test |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
105 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
106 %! unwind_protect |
13096 | 107 %! plot3 ([0,1], [0,1], [0,1]); |
108 %! [az, el] = view; | |
109 %! assert ([az, el], [-37.5, 30], eps); | |
110 %! view (2); | |
111 %! [az, el] = view; | |
112 %! assert ([az, el], [0, 90], eps); | |
113 %! view ([1 1 0]); | |
114 %! [az, el] = view; | |
115 %! assert ([az, el], [135, 0], eps); | |
116 %! unwind_protect_cleanup | |
117 %! close (hf); | |
118 %! end_unwind_protect | |
119 | |
120 %!test | |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13096
diff
changeset
|
121 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
122 %! unwind_protect |
13096 | 123 %! line; |
124 %! [az, el] = view; | |
125 %! assert ([az, el], [0, 90], eps); | |
126 %! view (3); | |
127 %! [az, el] = view; | |
128 %! assert ([az, el], [-37.5, 30], eps); | |
129 %! unwind_protect_cleanup | |
130 %! close (hf); | |
131 %! end_unwind_protect | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
132 |