Mercurial > hg > octave-lyh
annotate scripts/plot/contourf.m @ 17455:359366a4994f
waitbar.m: Use Octave coding conventions.
* scripts/plot/waitbar.m: Rename 'retval' to 'h' to match documentation.
Use 'hf', 'hp' for figure and patch graphics handles.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 19 Sep 2013 14:26:47 -0700 |
parents | 68bcac3c043a |
children | 177147bf7b55 |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
14092
diff
changeset
|
1 ## Copyright (C) 2007-2012 Kai Habel |
7042 | 2 ## Copyright (C) 2003 Shai Ayal |
3 ## | |
7164 | 4 ## This file is part of Octave. |
5 ## | |
6 ## Octave is free software; you can redistribute it and/or modify it | |
7042 | 7 ## under the terms of the GNU General Public License as published by |
7164 | 8 ## the Free Software Foundation; either version 3 of the License, or (at |
9 ## your option) any later version. | |
7042 | 10 ## |
7164 | 11 ## Octave is distributed in the hope that it will be useful, but |
7042 | 12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 ## General Public License for more details. | |
15 ## | |
16 ## You should have received a copy of the GNU General Public License | |
7164 | 17 ## along with Octave; see the file COPYING. If not, see |
18 ## <http://www.gnu.org/licenses/>. | |
7042 | 19 |
20 ## -*- texinfo -*- | |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
21 ## @deftypefn {Function File} {} contourf (@var{z}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
22 ## @deftypefnx {Function File} {} contourf (@var{z}, @var{vn}) |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
23 ## @deftypefnx {Function File} {} contourf (@var{x}, @var{y}, @var{z}) |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
24 ## @deftypefnx {Function File} {} contourf (@var{x}, @var{y}, @var{z}, @var{vn}) |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
25 ## @deftypefnx {Function File} {} contourf (@dots{}, @var{style}) |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
26 ## @deftypefnx {Function File} {} contourf (@var{hax}, @dots{}) |
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
27 ## @deftypefnx {Function File} {[@var{c}, @var{h}] =} contourf (@dots{}) |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
28 ## Create a 2-D contour plot with filled intervals. |
7042 | 29 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
30 ## Plot level curves (contour lines) of the matrix @var{z} and fill the region |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
31 ## between lines with colors from the current colormap. |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
32 ## |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
33 ## The level curves are taken from the contour matrix @var{c} computed by |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
34 ## @code{contourc} for the same arguments; see the latter for their |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
35 ## interpretation. |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
36 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
37 ## 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
|
38 ## 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
|
39 ## Any markers defined by @var{style} are ignored. |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
40 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
41 ## If the first argument @var{hax} is an axes handle, then plot into this axis, |
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
42 ## rather than the current axes returned by @code{gca}. |
16814
64e7bb01fce2
doc: Improve documentation for 2-D plot functions
Rik <rik@octave.org>
parents:
14247
diff
changeset
|
43 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
44 ## The optional output @var{c} are the contour levels in @code{contourc} format. |
7042 | 45 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
46 ## 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
|
47 ## comprising the contour lines. |
7042 | 48 ## |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
49 ## The following example plots filled contours of the @code{peaks} function. |
10821
693e22af08ae
Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents:
10793
diff
changeset
|
50 ## |
7042 | 51 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
52 ## @group |
7042 | 53 ## [x, y, z] = peaks (50); |
54 ## contourf (x, y, z, -7:9) | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
55 ## @end group |
7042 | 56 ## @end example |
17126
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
57 ## @seealso{ezcontourf, contour, contourc, contour3, clabel, meshc, surfc, caxis, colormap, plot} |
7042 | 58 ## @end deftypefn |
59 | |
60 ## Author: Kai Habel <kai.habel@gmx.de> | |
7327 | 61 ## Author: Shai Ayal <shaiay@users.sourceforge.net> |
7042 | 62 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
63 function [c, h] = contourf (varargin) |
7042 | 64 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
65 [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); |
7042 | 66 |
17219
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17198
diff
changeset
|
67 oldfig = []; |
17309
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17265
diff
changeset
|
68 if (! isempty (hax)) |
17219
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17198
diff
changeset
|
69 oldfig = get (0, "currentfigure"); |
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17198
diff
changeset
|
70 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
71 unwind_protect |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
72 hax = newplot (hax); |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
73 |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
74 [ctmp, htmp] = __contour__ (hax, "none", "fill", "on", |
10549 | 75 "linecolor", "black", varargin{:}); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
76 unwind_protect_cleanup |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
77 if (! isempty (oldfig)) |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
78 set (0, "currentfigure", oldfig); |
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
79 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
80 end_unwind_protect |
7570
8bf1bcb0ad8f
set axes layer property to "top"
John W. Eaton <jwe@octave.org>
parents:
7331
diff
changeset
|
81 |
7042 | 82 if (nargout > 0) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
83 c = ctmp; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
84 h = htmp; |
7042 | 85 endif |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
86 |
7042 | 87 endfunction |
7245 | 88 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
89 |
7245 | 90 %!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
|
91 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
92 %! colormap ('default'); |
7245 | 93 %! [x, y, z] = peaks (50); |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
94 %! contourf (x, y, z, -7:9); |
17265
ce55a8575874
Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
95 %! title ({'contourf() plot (filled contour lines)'; 'Z = peaks()'}); |
7327 | 96 |
97 %!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
|
98 %! clf; |
14247
c4fa5e0b6193
test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents:
14237
diff
changeset
|
99 %! 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
|
100 %! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); |
7331 | 101 %! [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
|
102 %! Z = sin (2*theta) .* (1-r); |
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
103 %! contourf (X, Y, abs (Z), 10); |
17265
ce55a8575874
Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents:
17219
diff
changeset
|
104 %! title ({'contourf() plot'; 'polar fcn: Z = sin (2*theta) * (1-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
|
105 |
17198
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
106 %!demo |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
107 %! clf; |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
108 %! colormap ('default'); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
109 %! x = linspace (-2, 2); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
110 %! [x, y] = meshgrid (x); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
111 %! z = sqrt (x.^2 + y.^2) ./ (x.^2 + y.^2 + 1); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
112 %! contourf (x, y, z, [0.4, 0.4]); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
113 %! title ('Hole should be filled with the background color'); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17130
diff
changeset
|
114 |