1 ## Copyright (C) 2007-2012 Kai Habel
3 ## This file is part of Octave.
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.
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.
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/>.
20 ## @deftypefn {Function File} {} ribbon (@var{x}, @var{y}, @var{width})
21 ## @deftypefnx {Function File} {} ribbon (@var{y})
22 ## @deftypefnx {Function File} {@var{h} =} ribbon (@dots{})
23 ## Plot a ribbon plot for the columns of @var{y} vs. @var{x}. The
24 ## optional parameter @var{width} specifies the width of a single ribbon
25 ## (default is 0.75). If @var{x} is omitted, a vector containing the
26 ## row numbers is assumed (1:rows(Y)).
28 ## The optional return value @var{h} is a vector of graphics handles to
29 ## the surface objects representing each ribbon.
32 ## Author: Kai Habel <kai.habel at gmx.de>
34 function h = ribbon (x, y, width)
44 x = repmat ((1:nr)', 1, nc);
52 if (isvector (x) && isvector (y))
53 if (length (x) != length (y))
54 error ("ribbon: in case of vectors, X and Y must have same length");
56 [x, y] = meshgrid (x, y);
59 if (! size_equal(x, y))
60 error ("ribbon: in case of matrices, X and Y must have same size");
68 zz = [y(:,c), y(:,c)];
70 xx = [c - width / 2, c + width / 2];
71 [xx, yy] = meshgrid (xx, yy);
72 cc = ones (size (zz)) * c;
73 tmp(c) = surface (xx, yy, zz, cc);
76 ax = get (tmp(c), "parent");
79 set (ax, "view", [-37.5, 30], "box", "off", "xgrid", "on",
80 "ygrid", "on", "zgrid", "on");
92 %! [x, y, z] = sombrero ();
93 %! [x, y] = meshgrid (x, y);