Mercurial > hg > octave-nkf
annotate scripts/plot/draw/contourf.m @ 20737:2d9ec16fa960
Print error, rather than aborting, if mex function mxIsFromGlobalWS is used (bug #46070).
* mex.cc (mxIsFromGlobalWS): Call mexErrMsgTxt rather than abort() in function.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 29 Sep 2015 12:00:11 -0700 |
parents | 777f26aa8e3e |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19790
diff
changeset
|
1 ## Copyright (C) 2007-2015 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 -*- | |
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 | 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 ## |
20383
777f26aa8e3e
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
44 ## 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:
19898
diff
changeset
|
45 ## format. |
7042 | 46 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
47 ## 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
|
48 ## comprising the contour lines. |
7042 | 49 ## |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
50 ## 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
|
51 ## |
7042 | 52 ## @example |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
53 ## @group |
7042 | 54 ## [x, y, z] = peaks (50); |
55 ## contourf (x, y, z, -7:9) | |
9051
1bf0ce0930be
Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
56 ## @end group |
7042 | 57 ## @end example |
17122
eaab03308c0b
doc: Rewrite docstrings for most plot functions.
Rik <rik@octave.org>
parents:
17050
diff
changeset
|
58 ## @seealso{ezcontourf, contour, contourc, contour3, clabel, meshc, surfc, caxis, colormap, plot} |
7042 | 59 ## @end deftypefn |
60 | |
61 ## Author: Kai Habel <kai.habel@gmx.de> | |
7327 | 62 ## Author: Shai Ayal <shaiay@users.sourceforge.net> |
7042 | 63 |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
64 function [c, h] = contourf (varargin) |
7042 | 65 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
66 [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); |
7042 | 67 |
17211
87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
Rik <rik@octave.org>
parents:
17190
diff
changeset
|
68 oldfig = []; |
17301
68bcac3c043a
Correct inversion accidentally introduced in cset 87ba70043bfc.
Rik <rik@octave.org>
parents:
17257
diff
changeset
|
69 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
|
70 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
|
71 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
72 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
|
73 hax = newplot (hax); |
19790
446c46af4b42
strip trailing whitespace from most source files
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
74 |
17050
9ff7d4849f03
contour[3f].m: Update to use new __plt_get_axis_arg__.
Pantxo Diribarne <pantxo.diribarne@gmail.com>
parents:
16814
diff
changeset
|
75 [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
|
76 "linecolor", "black", varargin{:}); |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
77 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
|
78 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
|
79 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
|
80 endif |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
81 end_unwind_protect |
7570
8bf1bcb0ad8f
set axes layer property to "top"
John W. Eaton <jwe@octave.org>
parents:
7331
diff
changeset
|
82 |
7042 | 83 if (nargout > 0) |
8289
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
84 c = ctmp; |
ac7f334d9652
Add contour group objects and the clabel function
David Bateman <dbateman@free.fr>
parents:
8227
diff
changeset
|
85 h = htmp; |
7042 | 86 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
|
87 |
7042 | 88 endfunction |
7245 | 89 |
14237
11949c9795a0
Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
90 |
7245 | 91 %!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
|
92 %! 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
|
93 %! colormap ('default'); |
7245 | 94 %! [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
|
95 %! contourf (x, y, z, -7:9); |
17257
ce55a8575874
Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
96 %! title ({'contourf() plot (filled contour lines)'; 'Z = peaks()'}); |
7327 | 97 |
98 %!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
|
99 %! 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
|
100 %! 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
|
101 %! [theta, r] = meshgrid (linspace (0,2*pi,64), linspace (0,1,64)); |
7331 | 102 %! [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
|
103 %! 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
|
104 %! contourf (X, Y, abs (Z), 10); |
17257
ce55a8575874
Fix typo in titles for contour/contourf demos.
Rik <rik@octave.org>
parents:
17211
diff
changeset
|
105 %! 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
|
106 |
17190
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
107 %!demo |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
108 %! clf; |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
109 %! colormap ('default'); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
110 %! x = linspace (-2, 2); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
111 %! [x, y] = meshgrid (x); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
112 %! 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
|
113 %! contourf (x, y, z, [0.4, 0.4]); |
df4c4b7708a4
Add titles and clean-up plotting %!demos.
Rik <rik@octave.org>
parents:
17126
diff
changeset
|
114 %! 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
|
115 |