16563
|
1 ## Copyright (C) 2013 Mike Miller |
|
2 ## |
|
3 ## This file is part of Octave. |
|
4 ## |
|
5 ## Octave is free software; you can redistribute it and/or modify it |
|
6 ## under the terms of the GNU General Public License as published by |
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
|
8 ## your option) any later version. |
|
9 ## |
|
10 ## Octave is distributed in the hope that it will be useful, but |
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 ## General Public License for more details. |
|
14 ## |
|
15 ## You should have received a copy of the GNU General Public License |
|
16 ## along with Octave; see the file COPYING. If not, see |
|
17 ## <http://www.gnu.org/licenses/>. |
|
18 |
|
19 ## -*- texinfo -*- |
|
20 ## @deftypefn {Function File} {} waterfall (@var{x}, @var{y}, @var{z}) |
|
21 ## @deftypefnx {Function File} {} waterfall (@var{z}) |
|
22 ## @deftypefnx {Function File} {@var{h} =} waterfall (@dots{}) |
|
23 ## Plot a waterfall plot given matrices @var{x}, and @var{y} from |
|
24 ## @code{meshgrid} and a matrix @var{z} corresponding to the @var{x} and |
|
25 ## @var{y} coordinates of the mesh. If @var{x} and @var{y} are vectors, |
|
26 ## then a typical vertex is (@var{x}(j), @var{y}(i), @var{z}(i,j)). Thus, |
|
27 ## columns of @var{z} correspond to different @var{x} values and rows of |
|
28 ## @var{z} correspond to different @var{y} values. |
|
29 ## |
|
30 ## The optional return value @var{h} is a graphics handle to the created |
|
31 ## surface object. |
|
32 ## @seealso{meshgrid, meshz, surf} |
|
33 ## @end deftypefn |
|
34 |
|
35 ## Author: Mike Miller <mtmiller@ieee.org> |
|
36 |
|
37 function h = waterfall (varargin) |
|
38 |
|
39 tmp = meshz (varargin{:}); |
|
40 |
|
41 set (tmp, "meshstyle", "row"); |
|
42 |
|
43 ## The gnuplot toolkit does nothing with the meshstyle property currently. |
|
44 toolkit = get (ancestor (tmp, "figure"), "__graphics_toolkit__"); |
|
45 if (strcmp (toolkit, "gnuplot")) |
|
46 warning ("waterfall: may not render correctly using toolkit '%s'", toolkit); |
|
47 endif |
|
48 |
|
49 if (nargout > 0) |
|
50 h = tmp; |
|
51 endif |
|
52 |
|
53 endfunction |
|
54 |
|
55 |
|
56 %!demo |
|
57 %! clf; |
|
58 %! colormap ('default'); |
|
59 %! [~,~,Z] = peaks (); |
|
60 %! waterfall (Z); |
|
61 |