annotate scripts/plot/contourf.m @ 17462:177147bf7b55

Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell. * scripts/plot/private/__pltopt__.m: Use modern coding conventions. Eliminate unneeded input checking in subfunctions. Remove unused variables. * scripts/plot/contourf.m, scripts/plot/feather.m, scripts/plot/plotmatrix.m, scripts/plot/private/__bar__.m, scripts/plot/private/__quiver__.m, scripts/plot/private/__scatter__.m, scripts/plot/private/__stem__.m, scripts/plot/stairs.m: Use iscellstr, not iscell, to properly validate inputs to __pltopt__.
author Rik <rik@octave.org>
date Mon, 23 Sep 2013 08:55:19 -0700
parents 68bcac3c043a
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
2 ## Copyright (C) 2003 Shai Ayal
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
3 ##
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
4 ## This file is part of Octave.
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
5 ##
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
9 ## your option) any later version.
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
10 ##
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
14 ## General Public License for more details.
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
15 ##
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7042
diff changeset
18 ## <http://www.gnu.org/licenses/>.
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
19
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
17122
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})
17122
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{})
17122
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
29 ##
17122
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 ##
17122
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 ##
17122
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 ##
17122
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
45 ##
17122
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
48 ##
17122
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
51 ## @example
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
52 ## @group
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
53 ## [x, y, z] = peaks (50);
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
56 ## @end example
17122
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
58 ## @end deftypefn
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
59
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
60 ## Author: Kai Habel <kai.habel@gmx.de>
7327
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7245
diff changeset
61 ## Author: Shai Ayal <shaiay@users.sourceforge.net>
7042
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
66
17211
87ba70043bfc Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents: 17190
diff changeset
67 oldfig = [];
17301
68bcac3c043a Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents: 17257
diff changeset
68 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
69 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
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",
17462
177147bf7b55 Overhaul use of __pltopt__.m to correctly check for cellstr, not just cell.
Rik <rik@octave.org>
parents: 17301
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
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
e54cc03d53f6 [project @ 2007-10-19 20:43:32 by jwe]
jwe
parents:
diff changeset
87 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
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
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
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
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
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);
17257
ce55a8575874 Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents: 17211
diff changeset
95 %! title ({'contourf() plot (filled contour lines)'; 'Z = peaks()'});
7327
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7245
diff changeset
96
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7245
diff changeset
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
3ed85de5922c [project @ 2007-12-21 17:40:20 by jwe]
jwe
parents: 7327
diff changeset
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);
17257
ce55a8575874 Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents: 17211
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
17190
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
106 %!demo
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
107 %! clf;
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
108 %! colormap ('default');
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
109 %! x = linspace (-2, 2);
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
diff changeset
110 %! [x, y] = meshgrid (x);
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
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: 17126
diff changeset
112 %! contourf (x, y, z, [0.4, 0.4]);
df4c4b7708a4 Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents: 17126
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: 17126
diff changeset
114