annotate scripts/plot/slice.m @ 17077:f8b485d09ac6

ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__. * scripts/plot/ribbon.m, scripts/plot/slice.m: Overhaul to use __plt_get_axis_arg__. Redo docstring.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:12:46 -0700
parents 6239f5806c26
children eaab03308c0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 14089
diff changeset
1 ## Copyright (C) 2007-2012 Kai Habel, David Bateman
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
2 ##
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
4 ##
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
8 ## your option) any later version.
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
9 ##
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
14 ##
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
18
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
20 ## @deftypefn {Function File} {} slice (@var{x}, @var{y}, @var{z}, @var{v}, @var{sx}, @var{sy}, @var{sz})
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
21 ## @deftypefnx {Function File} {} slice (@var{x}, @var{y}, @var{z}, @var{v}, @var{xi}, @var{yi}, @var{zi})
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
22 ## @deftypefnx {Function File} {} slice (@var{v}, @var{sx}, @var{sy}, @var{sz})
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
23 ## @deftypefnx {Function File} {} slice (@var{v}, @var{xi}, @var{yi}, @var{zi})
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
24 ## @deftypefnx {Function File} {} slice (@dots{}, @var{method})
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
25 ## @deftypefnx {Function File} {} slice (@var{hax}, @dots{})
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
26 ## @deftypefnx {Function File} {@var{h} =} slice (@dots{})
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
27 ## Plot slices of 3-D data/scalar fields.
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
28 ##
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
29 ## Each element of the 3-dimensional
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
30 ## array @var{v} represents a scalar value at a location given by the
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
31 ## parameters @var{x}, @var{y}, and @var{z}. The parameters @var{x},
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
32 ## @var{x}, and @var{z} are either 3-dimensional arrays of the same size
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
33 ## as the array @var{v} in the "meshgrid" format or vectors. The
9209
923c7cb7f13f Simplify TeXinfo files by eliminating redundant @iftex followed by @tex construction.
Rik <rdrider0-list@yahoo.com>
parents: 9051
diff changeset
34 ## parameters @var{xi}, etc. respect a similar format to @var{x}, etc.,
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
35 ## and they represent the points at which the array @var{vi} is
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
36 ## interpolated using interp3. The vectors @var{sx}, @var{sy}, and
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
37 ## @var{sz} contain points of orthogonal slices of the respective axes.
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
38 ##
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
39 ## If @var{x}, @var{y}, @var{z} are omitted, they are assumed to be
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
40 ## @code{x = 1:size (@var{v}, 2)}, @code{y = 1:size (@var{v}, 1)} and
11587
c792872f8942 all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents: 11563
diff changeset
41 ## @code{z = 1:size (@var{v}, 3)}.
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
42 ##
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
43 ## @var{method} is one of:
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
44 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
45 ## @table @asis
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
46 ## @item "nearest"
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
47 ## Return the nearest neighbor.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
48 ##
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
49 ## @item "linear"
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
50 ## Linear interpolation from nearest neighbors.
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
51 ##
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
52 ## @item "cubic"
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
53 ## Cubic interpolation from four nearest neighbors (not implemented yet).
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
54 ##
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
55 ## @item "spline"
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
56 ## Cubic spline interpolation---smooth first and second derivatives
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
57 ## throughout the curve.
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
58 ## @end table
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
59 ##
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
60 ## The default method is "linear".
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
61 ##
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
62 ## If the first argument @var{hax} is an axis handle, then plot into this axis,
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
63 ## rather than the current axis handle returned by @code{gca}.
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
64 ##
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
65 ## The optional return value @var{h} is a graphics handle to the created
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
66 ## surface object.
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
67 ##
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
68 ## Examples:
10821
693e22af08ae Grammarcheck documentation of m-files
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
69 ##
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
70 ## @example
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
71 ## @group
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
72 ## [x, y, z] = meshgrid (linspace (-8, 8, 32));
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
73 ## v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
74 ## slice (x, y, z, v, [], 0, []);
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
75 ##
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
76 ## [xi, yi] = meshgrid (linspace (-7, 7));
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
77 ## zi = xi + yi;
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
78 ## slice (x, y, z, v, xi, yi, zi);
9051
1bf0ce0930be Grammar check TexInfo in all .m files
Rik <rdrider0-list@yahoo.com>
parents: 9040
diff changeset
79 ## @end group
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
80 ## @end example
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
81 ## @seealso{interp3, surface, pcolor}
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
82 ## @end deftypefn
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
83
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
84 ## Author: Kai Habel <kai.habel@gmx.de>
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
85
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
86 function h = slice (varargin)
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
87
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
88 [hax, varargin, nargs] = __plt_get_axis_arg__ ("slice", varargin{:});
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
89
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
90 method = "linear";
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
91
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
92 if (ischar (varargin{end}))
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
93 method = varargin{end};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
94 nargs -= 1;
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
95 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
96
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
97 if (nargs == 4)
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
98 v = varargin{1};
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
99 if (ndims (v) != 3)
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
100 error ("slice: V must be a 3-dimensional array of values");
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
101 endif
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
102 [nx, ny, nz] = size (v);
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
103 [x, y, z] = meshgrid (1:nx, 1:ny, 1:nz);
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
104 sx = varargin{2};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
105 sy = varargin{3};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
106 sz = varargin{4};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
107 elseif (nargs == 7)
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
108 v = varargin{4};
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
109 if (ndims (v) != 3)
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
110 error ("slice: V must be a 3-dimensional array of values");
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
111 endif
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
112 x = varargin{1};
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
113 y = varargin{2};
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
114 z = varargin{3};
15009
6239f5806c26 Fix typos introduced by changeset 5d3a684236b0.
Rik <rik@octave.org>
parents: 14868
diff changeset
115 if (isvector (x) && isvector (y) && isvector (z))
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
116 [x, y, z] = meshgrid (x, y, z);
7292
5e90111a28b3 [project @ 2007-12-11 18:13:34 by jwe]
jwe
parents: 7245
diff changeset
117 elseif (ndims (x) == 3 && size_equal (x, y, z))
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
118 ## Do nothing.
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
119 else
8664
e07e93c04080 style fixes
John W. Eaton <jwe@octave.org>
parents: 7292
diff changeset
120 error ("slice: X, Y, Z size mismatch");
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
121 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
122 sx = varargin{5};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
123 sy = varargin{6};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
124 sz = varargin{7};
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
125 else
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
126 print_usage ();
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
127 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
128
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
129 if (any ([isvector(sx), isvector(sy), isvector(sz)]))
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
130 have_sval = true;
14868
5d3a684236b0 maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents: 14247
diff changeset
131 elseif (ndims (sx) == 2 && size_equal (sx, sy, sz))
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
132 have_sval = false;
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
133 else
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
134 error ("slice: dimensional mismatch for (XI, YI, ZI) or (SX, SY, SZ)");
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
135 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
136
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
137 oldfig = ifelse (isempty (hax), [], get (0, "currentfigure"));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
138 unwind_protect
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
139 hax = newplot (hax);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
140
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
141 sidx = 1;
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
142 minv = min (v(:));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
143 maxv = max (v(:));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
144 set (hax, "clim", [minv, maxv]);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
145
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
146 if (have_sval)
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
147 ns = length (sx) + length (sy) + length (sz);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
148 hs = zeros (ns,1);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
149 [ny, nx, nz] = size (v);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
150 if (length (sz) > 0)
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
151 for i = 1:length (sz)
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
152 [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)),
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
153 squeeze (y(:,1,1)), sz(i));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
154 vz = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
155 htmp(sidx++) = surface (xi, yi, sz(i) * ones (size (yi)), vz);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
156 endfor
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
157 endif
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
158
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
159 if (length (sy) > 0)
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
160 for i = length (sy):-1:1
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
161 [xi, yi, zi] = meshgrid (squeeze (x(1,:,1)), sy(i), squeeze (z(1,1,:)));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
162 vy = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
163 htmp(sidx++) = surface (squeeze (xi),
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
164 squeeze (sy(i) * ones (size (zi))),
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
165 squeeze (zi), vy);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
166 endfor
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
167 endif
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
168
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
169 if (length (sx) > 0)
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
170 for i = length (sx):-1:1
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
171 [xi, yi, zi] = meshgrid (sx(i), squeeze (y(:,1,1)), squeeze (z(1,1,:)));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
172 vx = squeeze (interp3 (x, y, z, v, xi, yi, zi, method));
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
173 htmp(sidx++) = surface (squeeze (sx(i) * ones (size (zi))),
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
174 squeeze (yi), squeeze(zi), vx);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
175 endfor
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
176 endif
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
177 else
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
178 vi = interp3 (x, y, z, v, sx, sy, sz);
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
179 htmp = surface (sx, sy, sz, vi);
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
180 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
181
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
182 if (! ishold ())
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
183 set (hax, "view", [-37.5, 30.0], "box", "off",
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
184 "xgrid", "on", "ygrid", "on", "zgrid", "on");
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
185 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
186
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
187 unwind_protect_cleanup
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
188 if (! isempty (oldfig))
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
189 set (0, "currentfigure", oldfig);
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
190 endif
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
191 end_unwind_protect
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
192
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
193 if (nargout > 0)
17077
f8b485d09ac6 ribbon.m, slice.m: Overhaul to use __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 15009
diff changeset
194 h = htmp;
7183
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
195 endif
c0be321eb472 [project @ 2007-11-26 18:31:53 by jwe]
jwe
parents:
diff changeset
196
7184
2f915d6cac3d [project @ 2007-11-26 18:45:02 by jwe]
jwe
parents: 7183
diff changeset
197 endfunction
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
198
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
199
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
200 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
201 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
202 %! colormap ('default');
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
203 %! [x, y, z] = meshgrid (linspace (-8, 8, 32));
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
204 %! v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
205 %! slice (x, y, z, v, [], 0, []);
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
206
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
207 %!demo
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
208 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
209 %! colormap ('default');
14086
41511cce0488 test: Fix 2nd demo for slice() (bug #35143)
Rik <octave@nomad.inbox5.com>
parents: 14001
diff changeset
210 %! [x, y, z] = meshgrid (linspace (-8, 8, 32));
41511cce0488 test: Fix 2nd demo for slice() (bug #35143)
Rik <octave@nomad.inbox5.com>
parents: 14001
diff changeset
211 %! v = sin (sqrt (x.^2 + y.^2 + z.^2)) ./ (sqrt (x.^2 + y.^2 + z.^2));
7245
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
212 %! [xi, yi] = meshgrid (linspace (-7, 7));
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
213 %! zi = xi + yi;
d65670971cbc [project @ 2007-12-04 03:03:54 by jwe]
jwe
parents: 7184
diff changeset
214 %! slice (x, y, z, v, xi, yi, zi);
14001
5f0bb45e615c doc: Update documentation for functions returning a graphics handle h (Bug #34761)
Rik <octave@nomad.inbox5.com>
parents: 11595
diff changeset
215