1
## Copyright (C) 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2002, 2004,
2
## 2005, 2006, 2007 John W. Eaton
4
## This file is part of Octave.
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.
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.
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/>.
21
## @deftypefn {Function File} {} surface (@var{x}, @var{y}, @var{z}, @var{c})
22
## @deftypefnx {Function File} {} surface (@var{x}, @var{y}, @var{z})
23
## @deftypefnx {Function File} {} surface (@var{z}, @var{c})
24
## @deftypefnx {Function File} {} surface (@var{z})
25
## @deftypefnx {Function File} {} surface (@dots{}, @var{prop}, @var{val})
26
## @deftypefnx {Function File} {} surface (@var{h}, @dots{})
27
## @deftypefnx {Function File} {@var{h} = } surface (@dots{})
28
## Plot a surface graphic object given matrices @var{x}, and @var{y} from
29
## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and
30
## @var{y} coordinates of the surface. If @var{x} and @var{y} are vectors,
31
## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus,
32
## columns of @var{z} correspond to different @var{x} values and rows of
33
## @var{z} correspond to different @var{y} values. If @var{x} and @var{y}
34
## are missing, they are constructed from size of the matrix @var{z}.
36
## Any additional properties passed are assigned the the surface..
37
## @seealso{surf, mesh, patch, line}
42
function retval = surface (varargin)
44
[h, varargin] = __plt_get_axis_arg__ ("surface", varargin{:});
49
[tmp, bad_usage] = __surface__ (h, varargin{:});
50
unwind_protect_cleanup
64
function [h, bad_usage] = __surface__ (ax, varargin)
70
if (ischar (varargin{i - 1}))
78
elseif (firststring == 5)
84
if (! size_equal (z, c))
85
error ("surface: z and c must have same size");
87
if (isvector (x) && isvector (y) && ismatrix (z))
88
if (rows (z) == length (y) && columns (z) == length (x))
92
error ("surface: rows (z) must be the same as length (y) and columns (z) must be the same as length (x)");
94
elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
95
if (! size_equal (x, y, z))
96
error ("surface: x, y, and z must have same dimensions");
99
error ("surface: x and y must be vectors and z must be a matrix");
101
elseif (firststring == 4)
106
if (isvector (x) && isvector (y) && ismatrix (z))
107
if (rows (z) == length (y) && columns (z) == length (x))
111
error ("surface: rows (z) must be the same as length (y) and columns (z) must be the same as length (x)");
113
elseif (ismatrix (x) && ismatrix (y) && ismatrix (z))
114
if (! size_equal (x, y, z))
115
error ("surface: x, y, and z must have same dimensions");
118
error ("surface: x and y must be vectors and z must be a matrix");
120
elseif (firststring == 3)
128
error ("surface: argument must be a matrix");
130
elseif (firststring == 2)
138
error ("surface: argument must be a matrix");
145
## Make a default surface object.
147
if (firststring < nargin)
148
other_args = varargin(firststring:end);
150
h = __go_surface__ (ax, "xdata", x, "ydata", y, "zdata", z, "cdata", c,
154
set (ax, "view", [0, 90], "box", "off");