Mercurial > octave
annotate scripts/plot/draw/contour.m @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 81d26e8481a6 |
children | 597f3ee61a48 |
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 ## |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30329
diff
changeset
|
3 ## Copyright (C) 1993-2022 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
27363
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/>. |
2313 | 7 ## |
6440 | 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 |
2313 | 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. |
2313 | 14 ## |
6440 | 15 ## Octave is distributed in the hope that it will be useful, but |
2313 | 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. |
2313 | 19 ## |
20 ## You should have received a copy of the GNU General Public License | |
7016 | 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 ######################################################################## |
245 | 25 |
3368 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
27 ## @deftypefn {} {} contour (@var{z}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
28 ## @deftypefnx {} {} contour (@var{z}, @var{vn}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
29 ## @deftypefnx {} {} contour (@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:
20173
diff
changeset
|
30 ## @deftypefnx {} {} contour (@var{x}, @var{y}, @var{z}, @var{vn}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
31 ## @deftypefnx {} {} contour (@dots{}, @var{style}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
32 ## @deftypefnx {} {} contour (@var{hax}, @dots{}) |
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20173
diff
changeset
|
33 ## @deftypefnx {} {[@var{c}, @var{h}] =} contour (@dots{}) |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
34 ## Create a 2-D contour plot. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
35 ## |
6604 | 36 ## Plot level curves (contour lines) of the matrix @var{z}, using the |
37 ## contour matrix @var{c} computed by @code{contourc} from the same | |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
38 ## arguments; see the latter for their interpretation. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
39 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
40 ## The appearance of contour lines can be defined with a line style @var{style} |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
41 ## in the same manner as @code{plot}. Only line style and color are used; |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
42 ## Any markers defined by @var{style} are ignored. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
43 ## |
24431
0c6cedafc71e
doc: Use 'axes' rather than 'axis' appropriately in docstrings.
Rik <rik@octave.org>
parents:
23219
diff
changeset
|
44 ## 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:
17050
diff
changeset
|
45 ## rather than the current axes returned by @code{gca}. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
46 ## |
20173
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
47 ## The optional output @var{c} contains the contour levels in @code{contourc} |
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
48 ## format. |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
49 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
50 ## The optional return value @var{h} is a graphics handle to the hggroup |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
51 ## comprising the contour lines. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
52 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
53 ## Example: |
6257 | 54 ## |
55 ## @example | |
6604 | 56 ## @group |
27363
d9d10a49926d
doc: Improve `contour` docstring example (bug #56849).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
57 ## x = 0:3; |
d9d10a49926d
doc: Improve `contour` docstring example (bug #56849).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
58 ## y = 0:2; |
d9d10a49926d
doc: Improve `contour` docstring example (bug #56849).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
59 ## z = y' * x; |
6604 | 60 ## contour (x, y, z, 2:3) |
61 ## @end group | |
6257 | 62 ## @end example |
7170 | 63 ## |
30329
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
64 ## @seealso{ezcontour, contourc, contourf, contour3, clabel, meshc, surfc, |
81d26e8481a6
maint: Shorten @seealso lines to less than 80 characters (bug #57599)
Rik <rik@octave.org>
parents:
29358
diff
changeset
|
65 ## caxis, colormap, plot} |
7317 | 66 ## |
3368 | 67 ## @end deftypefn |
4 | 68 |
7170 | 69 function [c, h] = contour (varargin) |
6434 | 70 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
71 [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); |
7216 | 72 |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
73 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17257
diff
changeset
|
74 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
|
75 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
|
76 endif |
7215 | 77 unwind_protect |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
78 hax = newplot (hax); |
19593
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
79 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
80 [ctmp, htmp] = __contour__ (hax, "none", varargin{:}); |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
81 |
22367
459545bc9019
Use ishold () rather than ishold (hax) for performance.
Rik <rik@octave.org>
parents:
22366
diff
changeset
|
82 if (! ishold ()) |
22366
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
83 set (hax, "box", "on"); |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
84 endif |
837df5db5710
Make graphic functions visually compatible w/Matlab.
Rik <rik@octave.org>
parents:
22323
diff
changeset
|
85 |
7215 | 86 unwind_protect_cleanup |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
87 if (! isempty (oldfig)) |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
88 set (0, "currentfigure", oldfig); |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16911
diff
changeset
|
89 endif |
7215 | 90 end_unwind_protect |
6257 | 91 |
92 if (nargout > 0) | |
7170 | 93 c = ctmp; |
7189 | 94 h = htmp; |
4 | 95 endif |
96 | |
97 endfunction | |
7245 | 98 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
99 |
7245 | 100 %!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
|
101 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
102 %! colormap ("default"); |
7245 | 103 %! [x, y, z] = peaks (); |
104 %! contour (x, y, z); | |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
105 %! title ({"contour() plot (isolines of constant Z)"; "Z = peaks()"}); |
7327 | 106 |
107 %!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
|
108 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
109 %! 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
|
110 %! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); |
7331 | 111 %! [X, Y] = pol2cart (theta, r); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
112 %! Z = sin (2*theta) .* (1-r); |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14247
diff
changeset
|
113 %! contour (X, Y, abs (Z), 10); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
114 %! title ({"contour() plot"; "polar fcn: Z = sin (2*theta) * (1-r)"}); |
13156
da71f676e449
Fix bug #34282. Fill holes in contours with the background colour
Ben Abbott <bpabbott@mac.com>
parents:
11587
diff
changeset
|
115 |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
116 %!demo |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
117 %! clf; |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
118 %! colormap ("default"); |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
119 %! z = peaks (); |
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
120 %! contour (z, [0 0]); |
22302
1c4cd12987f5
Use Octave syntax in graphics demos.
Rik <rik@octave.org>
parents:
21580
diff
changeset
|
121 %! title ({"contour() plot with single isoline at Z == 0"; "Z = peaks()"}); |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
122 |
16911 | 123 %!test |
124 %! hf = figure ("visible", "off"); | |
125 %! clf (hf); | |
126 %! unwind_protect | |
127 %! [x, y, z] = peaks (); | |
128 %! [c, h] = contour (x, y, z); | |
17525
76a6d7de4cbc
Fix multiple problem with listeners for contour groups.
Rik <rik@octave.org>
parents:
17301
diff
changeset
|
129 %! levellist = -6:6; |
16911 | 130 %! set (h, "levellist", levellist); |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
131 %! assert (get (h, "levellist"), levellist); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
132 %! assert (get (h, "levellistmode"), "manual"); |
16911 | 133 %! unwind_protect_cleanup |
134 %! close (hf); | |
135 %! end_unwind_protect | |
136 | |
137 %!test | |
138 %! hf = figure ("visible", "off"); | |
139 %! clf (hf); | |
140 %! unwind_protect | |
141 %! [x, y, z] = peaks (); | |
142 %! [c, h] = contour (x, y, z); | |
143 %! levelstep = 3; | |
144 %! set (h, "levelstep", levelstep); | |
21580
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
145 %! assert (get (h, "levelstep"), levelstep); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
146 %! assert (get (h, "levelstepmode"), "manual"); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
147 %! assert (get (h, "levellist"), -6:levelstep:6); |
ecce63c99c3f
maint: Add semicolons to terminate code in %! blocks.
Rik <rik@octave.org>
parents:
20852
diff
changeset
|
148 %! assert (get (h, "levellistmode"), "auto"); |
16911 | 149 %! unwind_protect_cleanup |
150 %! close (hf); | |
151 %! end_unwind_protect |