Mercurial > hg > octave-lyh
annotate scripts/plot/ribbon.m @ 14092:22c50cbad2ce stable
Add clf() to all plot demos.
* axis.m, compass.m, contour3.m, contourf.m, cylinder.m, ellipsoid.m,
errorbar.m, ezcontour.m, ezcontourf.m, ezmesh.m, ezmeshc.m, ezplot.m,
ezplot3.m, ezpolar.m, ezsurf.m, ezsurfc.m, feather.m, fplot.m,
loglogerr.m, pcolor.m, pie.m, pie3.m, plot3.m, plotmatrix.m,
quiver.m, quiver3.m, refreshdata.m, ribbon.m, rose.m, scatter3.m,
semilogx.m, semilogxerr.m, semilogy.m, semilogyerr.m, shading.m,
sombrero.m, stairs.m, stem.m, stem3.m, surf.m, surfc.m, surfl.m,
surfnorm.m, trimesh.m, triplot.m, trisurf.m, uimenu.m:
Add clf() to the beginning of each demo to ensure pre-existing graphics
objects don't interfere with the demo.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Wed, 21 Dec 2011 21:19:48 -0500 |
parents | 5f0bb45e615c |
children | 72c96de7a403 |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2007-2011 Kai Habel |
7163 | 2 ## |
7164 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
7163 | 6 ## under the terms of the GNU General Public License as published by |
7164 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
7163 | 9 ## |
7164 | 10 ## Octave is distributed in the hope that it will be useful, but |
7163 | 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 | |
7164 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
7163 | 18 |
19 ## -*- texinfo -*- | |
9143
74d5c1a4ca96
Eliminate 'unbalanced parentheses in @def...' error during texi2pdf.
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
20 ## @deftypefn {Function File} {} ribbon (@var{x}, @var{y}, @var{width}) |
74d5c1a4ca96
Eliminate 'unbalanced parentheses in @def...' error during texi2pdf.
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
21 ## @deftypefnx {Function File} {} ribbon (@var{y}) |
74d5c1a4ca96
Eliminate 'unbalanced parentheses in @def...' error during texi2pdf.
Rik <rdrider0-list@yahoo.com>
parents:
9040
diff
changeset
|
22 ## @deftypefnx {Function File} {@var{h} =} ribbon (@dots{}) |
9040
dbd0c77e575e
Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents:
8920
diff
changeset
|
23 ## Plot a ribbon plot for the columns of @var{y} vs. @var{x}. The |
7164 | 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 | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
26 ## row numbers is assumed (1:rows(Y)). |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
27 ## |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
28 ## The optional return value @var{h} is a vector of graphics handles to |
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
29 ## the surface objects representing each ribbon. |
7163 | 30 ## @end deftypefn |
31 | |
32 ## Author: Kai Habel <kai.habel at gmx.de> | |
33 | |
7166 | 34 function h = ribbon (x, y, width) |
7163 | 35 |
36 newplot (); | |
37 | |
38 if (nargin == 1) | |
7166 | 39 y = x; |
40 if (isvector (y)) | |
41 y = y(:); | |
7163 | 42 endif |
7166 | 43 [nr, nc] = size (y); |
44 x = repmat ((1:nr)', 1, nc); | |
45 width = 0.75; | |
7163 | 46 elseif (nargin == 2) |
7166 | 47 width = 0.75; |
7164 | 48 elseif (nargin != 3) |
49 print_usage (); | |
8610
85c9906abfd1
use endif and endfor instead of end
John W. Eaton <jwe@octave.org>
parents:
7650
diff
changeset
|
50 endif |
7163 | 51 |
7166 | 52 if (isvector (x) && isvector (y)) |
53 if (length (x) != length (y)) | |
8664 | 54 error ("ribbon: in case of vectors, X and Y must have same length"); |
7163 | 55 else |
7166 | 56 [x, y] = meshgrid (x, y); |
7163 | 57 endif |
58 else | |
7292 | 59 if (! size_equal(x, y)) |
8664 | 60 error ("ribbon: in case of matrices, X and Y must have same size"); |
7163 | 61 endif |
62 endif | |
63 | |
7166 | 64 [nr, nc] = size (y); |
7164 | 65 tmp = zeros (1, nc); |
7163 | 66 |
67 for c = nc:-1:1 | |
7166 | 68 zz = [y(:,c), y(:,c)]; |
69 yy = x(:,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); | |
7163 | 74 endfor |
75 | |
76 ax = get (tmp(c), "parent"); | |
77 | |
7164 | 78 if (! ishold ()) |
79 set (ax, "view", [-37.5, 30], "box", "off", "xgrid", "on", | |
10549 | 80 "ygrid", "on", "zgrid", "on"); |
7163 | 81 endif |
82 | |
83 if (nargout > 0) | |
84 h = tmp; | |
85 endif | |
7164 | 86 |
87 endfunction | |
7269 | 88 |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
89 |
7269 | 90 %!demo |
14092
22c50cbad2ce
Add clf() to all plot demos.
Ben Abbott <bpabbott@mac.com>
parents:
14001
diff
changeset
|
91 %! clf |
7269 | 92 %! [x, y, z] = sombrero (); |
93 %! [x, y] = meshgrid (x, y); | |
94 %! ribbon (y, z); | |
14001
5f0bb45e615c
doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents:
11523
diff
changeset
|
95 |