Mercurial > hg > octave-lyh
annotate scripts/plot/view.m @ 17059:c935a0db31c6
errorbar.m: Update to use new __plt_get_axis_arg__.
* scripts/plot/errorbar.m: Update to use new __plt_get_axis_arg__.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 24 Jul 2013 23:12:46 -0700 |
parents | df643a532b61 |
children | eaab03308c0b |
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 -*- | |
11563
3c6e8aaa9555
Grammarcheck m-files before 3.4 release.
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
20 ## @deftypefn {Function File} {[@var{azimuth}, @var{elevation}] =} view () |
12575
d0b799dafede
Grammarcheck files for 3.4.1 release.
Rik <octave@nomad.inbox5.com>
parents:
12344
diff
changeset
|
21 ## @deftypefnx {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
|
22 ## @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
|
23 ## @deftypefnx {Function File} {} view ([@var{x} @var{y} @var{z}]) |
16356 | 24 ## @deftypefnx {Function File} {} view (2) |
25 ## @deftypefnx {Function File} {} view (3) | |
11344 | 26 ## @deftypefnx {Function File} {} view (@var{ax}, @dots{}) |
12344
68ac95d2460c
Periodic grammarcheck of documentation.
Rik <octave@nomad.inbox5.com>
parents:
11587
diff
changeset
|
27 ## Query or set the viewpoint for the current axes. The parameters |
11344 | 28 ## @var{azimuth} and @var{elevation} can be given as two arguments or as |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11567
diff
changeset
|
29 ## 2-element vector. |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11567
diff
changeset
|
30 ## The viewpoint can also be given with Cartesian coordinates @var{x}, |
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11567
diff
changeset
|
31 ## @var{y}, and @var{z}. |
11344 | 32 ## 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
|
33 ## and @var{elevation} = 90, which is the default for 2-D graphs. |
11344 | 34 ## 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
|
35 ## and @var{elevation} = 30, which is the default for 3-D graphs. |
11344 | 36 ## If @var{ax} is given, the viewpoint is set for this axes, otherwise |
37 ## it is set for the current axes. | |
6257 | 38 ## @end deftypefn |
39 | |
40 ## Author: jwe | |
41 | |
11344 | 42 function [azimuth, elevation] = view (varargin) |
6257 | 43 |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
44 if (nargin < 4) |
7712
a626db2e8a1c
view: get values from current axes if nargin == 0
John W. Eaton <jwe@octave.org>
parents:
7016
diff
changeset
|
45 if (nargin == 0) |
11391
98d523608f70
view.m: Return azimuth and elevation for nargin == 0.
Ben Abbott <bpabbott@mac.com>
parents:
11345
diff
changeset
|
46 args = {get(gca (), "view")}; |
11344 | 47 else |
48 ax = varargin{1}; | |
49 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
|
50 args = varargin(2:end); |
11344 | 51 else |
52 ax = gca; | |
53 args = varargin; | |
54 endif | |
55 endif | |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
56 if (length (args) == 1) |
11344 | 57 x = args{1}; |
58 if (length (x) == 2) | |
59 az = x(1); | |
60 el = x(2); | |
61 elseif (length (x) == 3) | |
62 [az, el] = cart2sph (x(1), x(2), x(3)); | |
63 az *= 180/pi; | |
64 az += 90; | |
65 el *= 180/pi; | |
66 elseif (x == 2) | |
10549 | 67 az = 0; |
68 el = 90; | |
6257 | 69 elseif (x == 3) |
10549 | 70 az = -37.5; |
71 el = 30; | |
6257 | 72 else |
11344 | 73 print_usage (); |
6257 | 74 endif |
11345
488f07b65b1d
Fix bugs of previous changeset
Kai Habel <kai.habel@gmx.de>
parents:
11344
diff
changeset
|
75 elseif (length (args) == 2) |
11344 | 76 az = args{1}; |
77 el = args{2}; | |
6257 | 78 endif |
79 | |
80 if (nargin > 0) | |
11344 | 81 set (ax, "view", [az, el]); |
6257 | 82 endif |
83 | |
84 if (nargout == 1) | |
85 error ("view: T = view () not implemented"); | |
86 endif | |
87 | |
88 if (nargout == 2) | |
89 azimuth = az; | |
90 elevation = el; | |
91 endif | |
92 else | |
93 print_usage (); | |
94 endif | |
95 | |
96 endfunction | |
13096 | 97 |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
98 |
13096 | 99 %!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
|
100 %! 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
|
101 %! unwind_protect |
13096 | 102 %! plot3 ([0,1], [0,1], [0,1]); |
103 %! [az, el] = view; | |
104 %! assert ([az, el], [-37.5, 30], eps); | |
105 %! view (2); | |
106 %! [az, el] = view; | |
107 %! assert ([az, el], [0, 90], eps); | |
108 %! view ([1 1 0]); | |
109 %! [az, el] = view; | |
110 %! assert ([az, el], [135, 0], eps); | |
111 %! unwind_protect_cleanup | |
112 %! close (hf); | |
113 %! end_unwind_protect | |
114 | |
115 %!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
|
116 %! 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
|
117 %! unwind_protect |
13096 | 118 %! line; |
119 %! [az, el] = view; | |
120 %! assert ([az, el], [0, 90], eps); | |
121 %! view (3); | |
122 %! [az, el] = view; | |
123 %! assert ([az, el], [-37.5, 30], eps); | |
124 %! unwind_protect_cleanup | |
125 %! close (hf); | |
126 %! end_unwind_protect | |
14363
f3d52523cde1
Use Octave coding conventions in all m-file %!test blocks
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
127 |