Mercurial > octave
annotate scripts/plot/draw/surface.m @ 29359:7854d5752dd2
maint: merge stable to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Feb 2021 10:10:40 -0500 |
parents | 3cac3ceb9629 0a5b15007766 |
children | 796f54d4ddbf |
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:
28093
diff
changeset
|
3 ## Copyright (C) 1993-2021 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27898
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/>. |
7109 | 7 ## |
8 ## This file is part of Octave. | |
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 |
7109 | 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:
22351
diff
changeset
|
13 ## (at your option) any later version. |
7109 | 14 ## |
15 ## Octave is distributed in the hope that it will be useful, but | |
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22351
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22351
diff
changeset
|
18 ## GNU General Public License for more details. |
7109 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
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 ######################################################################## |
7109 | 25 |
26 ## -*- texinfo -*- | |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
27 ## @deftypefn {} {} surface (@var{x}, @var{y}, @var{z}, @var{c}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
28 ## @deftypefnx {} {} surface (@var{x}, @var{y}, @var{z}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
29 ## @deftypefnx {} {} surface (@var{z}, @var{c}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
30 ## @deftypefnx {} {} surface (@var{z}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
31 ## @deftypefnx {} {} surface (@dots{}, @var{prop}, @var{val}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
32 ## @deftypefnx {} {} surface (@var{hax}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19833
diff
changeset
|
33 ## @deftypefnx {} {@var{h} =} surface (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
34 ## Create a surface graphic object given matrices @var{x} and @var{y} from |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
35 ## @code{meshgrid} and a matrix of values @var{z} corresponding to the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
36 ## @var{x} and @var{y} coordinates of the surface. |
7175 | 37 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
38 ## If @var{x} and @var{y} are vectors, then a typical vertex is |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
39 ## (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus, columns of @var{z} correspond |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
40 ## to different @var{x} values and rows of @var{z} correspond to different |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
41 ## @var{y} values. If only a single input @var{z} is given then @var{x} is |
24319
3cdd2b6c78cb
doc: Correct surface plot explanation of meshgridded results of 1 input (bug #52536)
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
42 ## taken to be @code{1:columns (@var{z})} and @var{y} is |
3cdd2b6c78cb
doc: Correct surface plot explanation of meshgridded results of 1 input (bug #52536)
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
43 ## @code{1:rows (@var{z})}. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
44 ## |
24551
a7b6502b5cb5
doc: Add @ref from graphic object creation functions to list of graphic properties (bug #52816).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
45 ## Any property/value input pairs are assigned to the surface object. |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
46 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
24319
diff
changeset
|
47 ## 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:
17040
diff
changeset
|
48 ## rather than the current axes returned by @code{gca}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17040
diff
changeset
|
49 ## |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13194
diff
changeset
|
50 ## The optional return value @var{h} is a graphics handle to the created |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13194
diff
changeset
|
51 ## surface object. |
24551
a7b6502b5cb5
doc: Add @ref from graphic object creation functions to list of graphic properties (bug #52816).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
52 ## |
a7b6502b5cb5
doc: Add @ref from graphic object creation functions to list of graphic properties (bug #52816).
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
53 ## Programming Note: The full list of properties is documented at |
28093
05c1217d0dae
doc: Create better looking cross references in Info format (bug #57845).
Rik <rik@octave.org>
parents:
27923
diff
changeset
|
54 ## @ref{Surface Properties}. |
7109 | 55 ## @seealso{surf, mesh, patch, line} |
56 ## @end deftypefn | |
57 | |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
58 function h = surface (varargin) |
7109 | 59 |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
60 [hax, varargin] = __plt_get_axis_arg__ ("surface", varargin{:}); |
7215 | 61 |
17040
55b76fd1244b
surface.m: Update to use new __plt_get_axis_arg__ without using "axes" function.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16986
diff
changeset
|
62 if (isempty (hax)) |
55b76fd1244b
surface.m: Update to use new __plt_get_axis_arg__ without using "axes" function.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16986
diff
changeset
|
63 hax = gca (); |
17720
1ab8e21d9cfc
Further corrections to parenting of axes (bug #39813)
Rik <rik@octave.org>
parents:
17572
diff
changeset
|
64 else |
1ab8e21d9cfc
Further corrections to parenting of axes (bug #39813)
Rik <rik@octave.org>
parents:
17572
diff
changeset
|
65 hax = hax(1); |
17040
55b76fd1244b
surface.m: Update to use new __plt_get_axis_arg__ without using "axes" function.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16986
diff
changeset
|
66 endif |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
67 |
17040
55b76fd1244b
surface.m: Update to use new __plt_get_axis_arg__ without using "axes" function.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16986
diff
changeset
|
68 [htmp, bad_usage] = __surface__ (hax, varargin{:}); |
7109 | 69 |
7207 | 70 if (bad_usage) |
71 print_usage (); | |
72 endif | |
73 | |
74 if (nargout > 0) | |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
75 h = htmp; |
7207 | 76 endif |
7216 | 77 |
7207 | 78 endfunction |
79 | |
80 function [h, bad_usage] = __surface__ (ax, varargin) | |
81 | |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
82 h = 0; |
7207 | 83 bad_usage = false; |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 firststring = find (cellfun ("isclass", varargin, "char"), 1); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
85 if (isempty (firststring)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
86 firststring = nargin; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
87 endif |
7175 | 88 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
89 switch (firststring) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
90 case 5 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
91 x = varargin{1}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
92 y = varargin{2}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
93 z = varargin{3}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
94 c = varargin{4}; |
7175 | 95 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
96 if (iscomplex (x) || iscomplex (y) || iscomplex (z) || iscomplex (c)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
97 error ("mesh: X, Y, Z, C arguments must be real"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
98 endif |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
99 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
100 [z_nr, z_nc] = size (z); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
101 [c_nr, c_nc, c_np] = size (c); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
102 if (! (z_nr == c_nr && z_nc == c_nc && (c_np == 1 || c_np == 3))) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
103 error ("surface: Z and C must have the same size"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
104 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
105 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
106 if (isvector (x) && isvector (y) && ismatrix (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
107 if (rows (z) == length (y) && columns (z) == length (x)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
108 x = x(:)'; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
109 y = y(:); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
110 else |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
111 error ("surface: rows (Z) must be the same as length (Y) and columns (Z) must be the same as length (X)"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 endif |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 if (! size_equal (x, y, z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 error ("surface: X, Y, and Z must have the same dimensions"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
116 endif |
7109 | 117 else |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 error ("surface: X and Y must be vectors and Z must be a matrix"); |
7109 | 119 endif |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 case 4 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
122 x = varargin{1}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
123 y = varargin{2}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 z = varargin{3}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 c = z; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 if (iscomplex (x) || iscomplex (y) || iscomplex (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
128 error ("mesh: X, Y, Z arguments must be real"); |
7109 | 129 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
130 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 if (isvector (x) && isvector (y) && ismatrix (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
132 if (rows (z) == length (y) && columns (z) == length (x)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 x = x(:)'; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 y = y(:); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
135 else |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
136 error ("surface: rows (Z) must be the same as length (Y) and columns (Z) must be the same as length (X)"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
137 endif |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
138 elseif (ismatrix (x) && ismatrix (y) && ismatrix (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
139 if (! size_equal (x, y, z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
140 error ("surface: X, Y, and Z must have the same dimensions"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
141 endif |
7175 | 142 else |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
143 error ("surface: X and Y must be vectors and Z must be a matrix"); |
7175 | 144 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
145 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
146 case 3 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
147 z = varargin{1}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
148 c = varargin{2}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
149 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
150 if (iscomplex (z) || iscomplex (c)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
151 error ("mesh: X, C arguments must be real"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
152 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
153 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
154 if (ismatrix (z) && ! isvector (z) && ! isscalar (z)) |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
155 [nr, nc] = size (z); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
156 x = 1:nc; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
157 y = (1:nr)'; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
158 else |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
159 error ("surface: Z argument must be a matrix"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
160 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
161 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
162 case 2 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
163 z = varargin{1}; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
164 c = z; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
165 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
166 if (iscomplex (z)) |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
167 error ("mesh: Z argument must be real"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
168 endif |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
169 |
19833
9fc020886ae9
maint: Clean up m-files to follow Octave coding conventions.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
170 if (ismatrix (z) && ! isvector (z) && ! isscalar (z)) |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
171 [nr, nc] = size (z); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
172 x = 1:nc; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
173 y = (1:nr)'; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
174 else |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
175 error ("surface: Z argument must be a matrix"); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
176 endif |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
177 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
178 case 1 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
179 x = 1:3; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
180 y = x'; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
181 c = z = eye (3); |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
182 |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
183 otherwise |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
184 bad_usage = true; |
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
185 return; |
19597
db92e7e28e1f
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
19596
diff
changeset
|
186 |
18430
07ca8b9f8cab
surface.m: Simplify input argument processing.
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
187 endswitch |
7109 | 188 |
16986
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
189 if (firststring < nargin) |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
190 other_args = varargin(firststring:end); |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
191 else |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
192 other_args = {}; # make a default surface object. |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
193 endif |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
194 h = __go_surface__ (ax, "xdata", x, "ydata", y, "zdata", z, "cdata", c, |
df66488b8d43
surface.m: Validate inputs are not complex.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
195 other_args{:}); |
7109 | 196 |
25436
996d78102a71
maint: Strip trailing whitespace from source files.
John W. Eaton <jwe@octave.org>
parents:
25329
diff
changeset
|
197 ## FIXME: ishold called this way is very slow. |
25329
c8fc547ab5dd
Fix extra figure window pop-up when using waitbar (bug #53778)
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
198 if (! ishold (ax)) |
22351
e6df1ddfc3cf
Change DefaultAxesBox property to "off".
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
199 set (ax, "view", [0, 90]); |
7277 | 200 endif |
7109 | 201 |
202 endfunction | |
12817
e3e6079039c6
codesprint: 2 demos for pcolor.m dummy for surface.m
Kai Habel <kai.habel@gmx.de>
parents:
11587
diff
changeset
|
203 |
14223
ba7a26030214
Use Octave spacing convention in %!test blocks of surface plot functions.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
204 |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
13194
diff
changeset
|
205 ## Functional tests for surface() are in surf.m, surfc.m, surfl.m, and pcolor.m |
13115
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
206 %!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:
13115
diff
changeset
|
207 %! 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
|
208 %! unwind_protect |
28892
3cac3ceb9629
maint: Use coding style with parentheses after function name to distinguish from a variable.
Rik <rik@octave.org>
parents:
28093
diff
changeset
|
209 %! h = surface (); |
13115
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
210 %! assert (findobj (hf, "type", "surface"), h); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
211 %! assert (get (h, "xdata"), 1:3, eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
212 %! assert (get (h, "ydata"), (1:3)', eps); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14223
diff
changeset
|
213 %! assert (get (h, "zdata"), eye (3)); |
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14223
diff
changeset
|
214 %! assert (get (h, "cdata"), eye (3)); |
13115
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
215 %! assert (get (h, "type"), "surface"); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
216 %! assert (get (h, "linestyle"), get (0, "defaultsurfacelinestyle")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
217 %! assert (get (h, "linewidth"), get (0, "defaultsurfacelinewidth"), eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
218 %! assert (get (h, "marker"), get (0, "defaultsurfacemarker")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
219 %! assert (get (h, "markersize"), get (0, "defaultsurfacemarkersize")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
220 %! unwind_protect_cleanup |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
221 %! close (hf); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12819
diff
changeset
|
222 %! end_unwind_protect |