annotate scripts/plot/contour.m @ 7331:3ed85de5922c

[project @ 2007-12-21 17:40:20 by jwe]
author jwe
date Fri, 21 Dec 2007 17:41:35 +0000
parents 9af6f0a214ee
children ac7f334d9652
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7017
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
1 ## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
a1dbe9d80eee [project @ 2007-10-12 21:27:11 by jwe]
jwe
parents: 7016
diff changeset
2 ## 2003, 2004, 2005, 2006, 2007 Shai Ayal
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
3 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6434
diff changeset
4 ## This file is part of Octave.
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6434
diff changeset
5 ##
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6434
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
7 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
9 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
10 ##
6440
98ee80702bca [project @ 2007-03-23 15:13:19 by jwe]
jwe
parents: 6434
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
14 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
15 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2311
diff changeset
16 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6895
diff changeset
18 ## <http://www.gnu.org/licenses/>.
245
16a24e76d6e0 [project @ 1993-12-03 02:00:15 by jwe]
jwe
parents: 4
diff changeset
19
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3136
diff changeset
20 ## -*- texinfo -*-
7317
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
21 ## @deftypefn {Function File} {} contour (@var{z})
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
22 ## @deftypefnx {Function File} {} contour (@var{z}, @var{vn})
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
23 ## @deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z})
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
24 ## @deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z}, @var{vn})
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
25 ## @deftypefnx {Function File} {} contour (@dots{}, @var{style})
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
26 ## @deftypefnx {Function File} {} contour (@var{h}, @dots{})
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
27 ## @deftypefnx {Function File} {[@var{c}, @var{h}] =} contour (@dots{})
6604
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
28 ## Plot level curves (contour lines) of the matrix @var{z}, using the
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
29 ## contour matrix @var{c} computed by @code{contourc} from the same
6895
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6888
diff changeset
30 ## arguments; see the latter for their interpretation. The set of
76e3d985ae56 [project @ 2007-09-13 18:22:38 by jwe]
jwe
parents: 6888
diff changeset
31 ## contour levels, @var{c}, is only returned if requested. For example:
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
32 ##
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
33 ## @example
6604
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
34 ## @group
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
35 ## x = 0:2;
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
36 ## y = x;
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
37 ## z = x' * y;
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
38 ## contour (x, y, z, 2:3)
c2b700808e0a [project @ 2007-05-02 05:36:43 by jwe]
jwe
parents: 6547
diff changeset
39 ## @end group
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
40 ## @end example
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
41 ##
7317
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
42 ## The style to use for the plot can be defined with a line style @var{style}
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
43 ## in a similar manner to the line styles used with the @code{plot} command.
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
44 ## Any markers defined by @var{style} are ignored.
11c5f1ee553e [project @ 2007-12-14 17:42:55 by jwe]
jwe
parents: 7245
diff changeset
45 ##
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
46 ## The optional input and output argument @var{h} allows an axis handle to
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
47 ## be passed to @code{contour} and the handles to the contour objects to be
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
48 ## returned.
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
49 ## @seealso{contourc, patch, plot}
3368
a4cd1e9d9962 [project @ 1999-11-20 17:22:48 by jwe]
jwe
parents: 3136
diff changeset
50 ## @end deftypefn
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
51
7327
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7317
diff changeset
52 ## Author: Shai Ayal <shaiay@users.sourceforge.net>
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
53
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
54 function [c, h] = contour (varargin)
6434
7caa5942d4da [project @ 2007-03-23 13:59:29 by jwe]
jwe
parents: 6279
diff changeset
55
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
56 [xh, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
57
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
58 oldh = gca ();
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
59 unwind_protect
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
60 axes (xh);
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
61 newplot ();
7216
5389a52df87b [project @ 2007-11-29 19:07:29 by jwe]
jwe
parents: 7215
diff changeset
62 [ctmp, htmp] = __contour__ (xh, NaN, varargin{:});
7215
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
63 unwind_protect_cleanup
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
64 axes (oldh);
dd88d61d443f [project @ 2007-11-29 16:44:45 by jwe]
jwe
parents: 7189
diff changeset
65 end_unwind_protect
6257
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
66
44c91c5dfe1d [project @ 2007-01-30 19:16:52 by jwe]
jwe
parents: 6172
diff changeset
67 if (nargout > 0)
7170
9f38c6293317 [project @ 2007-11-13 17:34:33 by jwe]
jwe
parents: 7017
diff changeset
68 c = ctmp;
7189
e8d953d03f6a [project @ 2007-11-26 20:42:09 by dbateman]
dbateman
parents: 7170
diff changeset
69 h = htmp;
4
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
70 endif
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
71
b4df021f796c [project @ 1993-08-08 01:26:08 by jwe]
jwe
parents:
diff changeset
72 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
73
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
74 %!demo
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
75 %! [x, y, z] = peaks ();
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7216
diff changeset
76 %! contour (x, y, z);
7327
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7317
diff changeset
77
9af6f0a214ee [project @ 2007-12-19 21:39:02 by jwe]
jwe
parents: 7317
diff changeset
78 %!demo
7331
3ed85de5922c [project @ 2007-12-21 17:40:20 by jwe]
jwe
parents: 7327
diff changeset
79 %! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64));
3ed85de5922c [project @ 2007-12-21 17:40:20 by jwe]
jwe
parents: 7327
diff changeset
80 %! [X, Y] = pol2cart (theta, r);
3ed85de5922c [project @ 2007-12-21 17:40:20 by jwe]
jwe
parents: 7327
diff changeset
81 %! Z = sin(2*theta).*(1-r);
3ed85de5922c [project @ 2007-12-21 17:40:20 by jwe]
jwe
parents: 7327
diff changeset
82 %! contour(X, Y, abs(Z), 10)