annotate scripts/plot/shading.m @ 17074:bade805dc0af

shading.m: Update to use new __plt_get_axis_arg__. * scripts/plot/shading.m: Update to use new __plt_get_axis_arg__. Use switch instead of if/else tree. Eliminate unnecessary for loop.
author Rik <rik@octave.org>
date Wed, 24 Jul 2013 23:12:46 -0700
parents 5d3a684236b0
children c2b2c7ddf93c
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: 14092
diff changeset
1 ## Copyright (C) 2006-2012 Kai Habel
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
2 ##
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
3 ## This file is part of Octave.
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
4 ##
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
8 ## your option) any later version.
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
9 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
13 ## General Public License for more details.
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
14 ##
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
7164
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
2b5e6c0a9df9 [project @ 2007-11-12 22:04:42 by jwe]
jwe
parents: 7151
diff changeset
17 ## <http://www.gnu.org/licenses/>.
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
18
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
19 ## -*- texinfo -*-
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10635
diff changeset
20 ## @deftypefn {Function File} {} shading (@var{type})
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
21 ## @deftypefnx {Function File} {} shading (@var{ax}, @var{type})
9040
dbd0c77e575e Cleanup documentation file plot.texi
Rik <rdrider0-list@yahoo.com>
parents: 8920
diff changeset
22 ## Set the shading of surface or patch graphic objects. Valid arguments
7978
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
23 ## for @var{type} are
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
24 ##
11595
5ec6aa05638d Prevent doubled quotes around @table items in Info.
Rik <octave@nomad.inbox5.com>
parents: 11587
diff changeset
25 ## @table @asis
7978
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
26 ## @item "flat"
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
27 ## Single colored patches with invisible edges.
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
28 ##
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
29 ## @item "faceted"
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
30 ## Single colored patches with visible edges.
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
31 ##
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
32 ## @item "interp"
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
33 ## Color between patch vertices are interpolated and the patch edges are
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
34 ## invisible.
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
35 ## @end table
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
36 ##
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
37 ## If @var{hax} is given the shading is applied to axis @var{hax} instead
7978
f8514786c490 Clarify help of the shading function
David Bateman <dbateman@free.fr>
parents: 7249
diff changeset
38 ## of the current axis.
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
39 ## @end deftypefn
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
40
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
41 ## Author: Kai Habel <kai.habel@gmx.de>
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
42
7249
87b5a3fb5286 [project @ 2007-12-04 18:04:23 by jwe]
jwe
parents: 7164
diff changeset
43 function shading (varargin)
87b5a3fb5286 [project @ 2007-12-04 18:04:23 by jwe]
jwe
parents: 7164
diff changeset
44
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
45 [hax, varargin, nargin] = __plt_get_axis_arg__ ("shading", varargin{:});
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
46
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
47 if (nargin != 1)
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
48 print_usage ();
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
49 endif
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
50
7249
87b5a3fb5286 [project @ 2007-12-04 18:04:23 by jwe]
jwe
parents: 7164
diff changeset
51 mode = varargin{1};
87b5a3fb5286 [project @ 2007-12-04 18:04:23 by jwe]
jwe
parents: 7164
diff changeset
52
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
53 if (isempty (hax))
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
54 hax = gca ();
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
55 endif
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
56
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
57 hp = findobj (hax, "type", "patch");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
58 hs = findobj (hax, "type", "surface");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
59 hall = [hp(:); hs(:)];
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
60
17074
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
61 switch (lower (mode))
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
62 case "flat"
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
63 set (hall, "facecolor", "flat");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
64 set (hall, "edgecolor", "none");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
65 case "interp"
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
66 set (hall, "facecolor", "interp");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
67 set (hall, "edgecolor", "none");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
68 case "faceted"
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
69 set (hall, "facecolor", "flat");
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
70 set (hall, "edgecolor", [0 0 0]);
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
71 otherwise
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
72 error ('shading: Invalid MODE "%s"', mode);
bade805dc0af shading.m: Update to use new __plt_get_axis_arg__.
Rik <rik@octave.org>
parents: 14868
diff changeset
73 endswitch
7110
0e63f1126f01 [project @ 2007-11-06 22:36:22 by jwe]
jwe
parents: 7109
diff changeset
74
7109
5436efbf35e3 [project @ 2007-11-06 22:16:25 by jwe]
jwe
parents:
diff changeset
75 endfunction
8166
4024fc815f8d __go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents: 7978
diff changeset
76
13967
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
77
8166
4024fc815f8d __go_draw_axes__.m: Fix interpolation of facecolors.
Ben Abbott <bpabbott@mac.com>
parents: 7978
diff changeset
78 %!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
79 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
80 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
81 %! sombrero ();
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
82 %! shading faceted;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
83 %! title ('shading ''faceted''');
13967
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
84
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
85 %!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
86 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
87 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
88 %! sombrero ();
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
89 %! shading flat;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
90 %! title ('shading ''flat''');
8765
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
91
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
92 %!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
93 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
94 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
95 %! sombrero ();
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
96 %! shading interp;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
97 %! title ('shading ''interp''');
8765
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
98
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
99 %!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
100 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
101 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
102 %! pcolor (peaks ());
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
103 %! shading faceted;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
104 %! title ('shading ''faceted''');
13967
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
105
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
106 %!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
107 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
108 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
109 %! pcolor (peaks ());
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
110 %! shading flat;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
111 %! title ('shading ''flat''');
8765
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
112
cf2163418140 Trivial change to shading.m and surfl.m demos.
Ben Abbott <bpabbott@mac.com>
parents: 8746
diff changeset
113 %!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
114 %! clf;
14247
c4fa5e0b6193 test: Make surface demos reproducible by setting colormap to default at start of demo.
Rik <octave@nomad.inbox5.com>
parents: 14245
diff changeset
115 %! colormap ('default');
14237
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
116 %! pcolor (peaks ());
11949c9795a0 Revamp %!demos in m-files to use Octave coding conventions on spacing, etc.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
117 %! shading interp;
14245
4506eade9f04 Use Matlab coding conventions for demos in plot/ directory.
Rik <octave@nomad.inbox5.com>
parents: 14237
diff changeset
118 %! title ('shading ''interp''');
13967
9ff0273cd054 shading.m: Add demos for 'flat' option
Rik <octave@nomad.inbox5.com>
parents: 12437
diff changeset
119