annotate scripts/plot/waterfall.m @ 16923:5d08a2ec7edb

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