Mercurial > octave
annotate scripts/plot/draw/surf.m @ 31706:597f3ee61a48 stable
update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 06 Jan 2023 13:11:27 -0500 |
parents | 796f54d4ddbf |
children | 2e484f9f1f18 |
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 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 2007-2023 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/>. |
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:
22367
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:
22367
diff
changeset
|
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22367
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:
19697
diff
changeset
|
27 ## @deftypefn {} {} surf (@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:
19697
diff
changeset
|
28 ## @deftypefnx {} {} surf (@var{z}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## @deftypefnx {} {} surf (@dots{}, @var{c}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
30 ## @deftypefnx {} {} surf (@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:
19697
diff
changeset
|
31 ## @deftypefnx {} {} surf (@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
|
32 ## @deftypefnx {} {@var{h} =} surf (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
33 ## Plot a 3-D surface mesh. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
34 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
35 ## The surface mesh is plotted using shaded rectangles. The vertices of the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
36 ## rectangles [@var{x}, @var{y}] are typically the output of @code{meshgrid}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
37 ## over a 2-D rectangular region in the x-y plane. @var{z} determines the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
38 ## height above the plane of each vertex. If only a single @var{z} matrix is |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
39 ## given, then it is plotted over the meshgrid |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
40 ## @code{@var{x} = 1:columns (@var{z}), @var{y} = 1:rows (@var{z})}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
41 ## Thus, columns of @var{z} correspond to different @var{x} values and rows |
17281
bc924baa2c4e
doc: Add new @qcode macro for code samples which are quoted.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
42 ## of @var{z} correspond to different @var{y} values. |
11101
1f9ab076f5f7
Include the 4 input (color) in the docstrings for mesh() and surf().
Ben Abbott <bpabbott@mac.com>
parents:
10549
diff
changeset
|
43 ## |
17450
43e0b711d7e0
doc: Correct accidental capitalization @var{Z} in mesh/surf docstrings.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
44 ## The color of the surface is computed by linearly scaling the @var{z} values |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
45 ## to fit the range of the current colormap. Use @code{caxis} and/or |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
46 ## change the colormap to control the appearance. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
47 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
48 ## Optionally, the color of the surface can be specified independently of |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
49 ## @var{z} by supplying a color matrix, @var{c}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
50 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
51 ## Any property/value pairs are passed directly to the underlying surface |
28733
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27978
diff
changeset
|
52 ## object. The full list of properties is documented at |
9342688e86b4
Updated property references for text and graphics functions (bug #50247)
Nicholas R. Jankowski <jankowskin@asme.org>
parents:
27978
diff
changeset
|
53 ## @ref{Surface Properties}. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
54 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
55 ## 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:
17121
diff
changeset
|
56 ## rather than the current axes returned by @code{gca}. |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
57 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
58 ## 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:
12812
diff
changeset
|
59 ## surface object. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
60 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
61 ## Note: The exact appearance of the surface can be controlled with the |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
62 ## @code{shading} command or by using @code{set} to control surface object |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17121
diff
changeset
|
63 ## properties. |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
64 ## @seealso{ezsurf, surfc, surfl, surfnorm, trisurf, contour, mesh, surface, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
65 ## meshgrid, hidden, shading, colormap, caxis} |
7109 | 66 ## @end deftypefn |
67 | |
24819
bdec5e695ec3
scatter3.m, surf.m: Match output variable name to documentation.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
68 function h = surf (varargin) |
7109 | 69 |
17052
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
70 [hax, varargin] = __plt_get_axis_arg__ ("surf", varargin{:}); |
7109 | 71 |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
72 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17281
diff
changeset
|
73 if (! isempty (hax)) |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
74 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
75 endif |
7215 | 76 unwind_protect |
17052
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
77 hax = newplot (hax); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
78 |
17052
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
79 htmp = surface (varargin{:}); |
7110 | 80 |
22367
459545bc9019
Use ishold () rather than ishold (hax) for performance.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 if (! ishold ()) |
17052
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
82 set (hax, "view", [-37.5, 30], |
17126
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
83 "xgrid", "on", "ygrid", "on", "zgrid", "on"); |
7215 | 84 endif |
17126
26589abbc78d
Don't pass axis handle unnecessarily from high level to low level plot functions.
Rik <rik@octave.org>
parents:
17122
diff
changeset
|
85 |
7215 | 86 unwind_protect_cleanup |
17052
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
87 if (! isempty (oldfig)) |
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
88 set (0, "currentfigure", oldfig); |
1118d566bcd4
surf.m, surfc.m, surfl.m, surfnorm.m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
14247
diff
changeset
|
89 endif |
7215 | 90 end_unwind_protect |
7110 | 91 |
7109 | 92 if (nargout > 0) |
24819
bdec5e695ec3
scatter3.m, surf.m: Match output variable name to documentation.
Rik <rik@octave.org>
parents:
24534
diff
changeset
|
93 h = htmp; |
7109 | 94 endif |
95 | |
96 endfunction | |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
97 |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
98 |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
99 %!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
|
100 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
101 %! colormap ("default"); |
17121
d4549655b92e
Rephrase %!tests to take advantage of single output form of peaks().
Rik <rik@octave.org>
parents:
17120
diff
changeset
|
102 %! Z = peaks (); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
103 %! surf (Z); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
104 %! title ({"surf() plot of peaks() function"; "color determined by height Z"}); |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
105 |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
106 %!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
|
107 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
108 %! colormap ("default"); |
17120
a639221f9863
sombrero.m: Overhaul documentation and make calling forms equivalent to peaks()
Rik <rik@octave.org>
parents:
17052
diff
changeset
|
109 %! Z = sombrero (); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
110 %! [Fx,Fy] = gradient (Z); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
111 %! surf (Z, Fx+Fy); |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
112 %! shading interp; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
113 %! title ({"surf() plot of peaks() function"; ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
114 %! "facecolor is interpolated, color determined by gradient of Z"}); |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
115 |
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
116 %!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
|
117 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
118 %! colormap ("default"); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
119 %! [X,Y,Z] = sombrero (); |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
120 %! [~,Fy] = gradient (Z); |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
12812
diff
changeset
|
121 %! surf (X, Y, Z, Fy); |
12812
4c93cc41da15
codesprint: add demo for surf.m and surfc.m
Kai Habel <kai.habel@gmx.de>
parents:
11575
diff
changeset
|
122 %! shading interp; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
123 %! title ({"surf() plot of peaks() function"; ... |
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
124 %! "facecolor is interpolated, color determined by Y-gradient of Z"}); |