changelog shortlog tags changeset files revisions annotate raw

scripts/plot/contour.m

changeset 10289: 4b124317dc38
parent:ac7f334d9652
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (49 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2002,
2## 2003, 2004, 2005, 2006, 2007, 2008 Shai Ayal
3##
4## This file is part of Octave.
5##
6## Octave is free software; you can redistribute it and/or modify it
7## under the terms of the GNU General Public License as published by
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
10##
11## Octave is distributed in the hope that it will be useful, but
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
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
19
20## -*- texinfo -*-
21## @deftypefn {Function File} {} contour (@var{z})
22## @deftypefnx {Function File} {} contour (@var{z}, @var{vn})
23## @deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z})
24## @deftypefnx {Function File} {} contour (@var{x}, @var{y}, @var{z}, @var{vn})
25## @deftypefnx {Function File} {} contour (@dots{}, @var{style})
26## @deftypefnx {Function File} {} contour (@var{h}, @dots{})
27## @deftypefnx {Function File} {[@var{c}, @var{h}] =} contour (@dots{})
28## Plot level curves (contour lines) of the matrix @var{z}, using the
29## contour matrix @var{c} computed by @code{contourc} from the same
30## arguments; see the latter for their interpretation. The set of
31## contour levels, @var{c}, is only returned if requested. For example:
32##
33## @example
34## @group
35## x = 0:2;
36## y = x;
37## z = x' * y;
38## contour (x, y, z, 2:3)
39## @end group
40## @end example
41##
42## The style to use for the plot can be defined with a line style @var{style}
43## in a similar manner to the line styles used with the @code{plot} command.
44## Any markers defined by @var{style} are ignored.
45##
46## The optional input and output argument @var{h} allows an axis handle to
47## be passed to @code{contour} and the handles to the contour objects to be
48## returned.
49## @seealso{contourc, patch, plot}
50## @end deftypefn
51
52## Author: Shai Ayal <shaiay@users.sourceforge.net>
53
54function [c, h] = contour (varargin)
55
56 [xh, varargin] = __plt_get_axis_arg__ ("contour", varargin{:});
57
58 oldh = gca ();
59 unwind_protect
60 axes (xh);
61 newplot ();
62 [ctmp, htmp] = __contour__ (xh, "none", varargin{:});
63 unwind_protect_cleanup
64 axes (oldh);
65 end_unwind_protect
66
67 if (nargout > 0)
68 c = ctmp;
69 h = htmp;
70 endif
71
72endfunction
73
74%!demo
75%! [x, y, z] = peaks ();
76%! contour (x, y, z);
77
78%!demo
79%! [theta, r] = meshgrid (linspace (0, 2*pi, 64), linspace(0,1,64));
80%! [X, Y] = pol2cart (theta, r);
81%! Z = sin(2*theta).*(1-r);
82%! contour(X, Y, abs(Z), 10)