Mercurial > hg > octave-lyh
annotate scripts/plot/patch.m @ 13802:630d3c80b541
allow axes handle to be passed to patch function
* patch.m: Accept axes handle argument. Don't call gca.
Eliminate unneeded unwind_protect block.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 03 Nov 2011 05:07:51 -0400 |
parents | e9f6a6edec42 |
children | 240d6810204c |
rev | line source |
---|---|
11523 | 1 ## Copyright (C) 2005-2011 John W. Eaton |
6807 | 2 ## |
3 ## This file is part of Octave. | |
4 ## | |
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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
6807 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
6807 | 18 |
19 ## -*- texinfo -*- | |
10793
be55736a0783
Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents:
9110
diff
changeset
|
20 ## @deftypefn {Function File} {} patch () |
6807 | 21 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
22 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{z}, @var{c}) |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
23 ## @deftypefnx {Function File} {} patch (@var{fv}) |
7020 | 24 ## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{}) |
25 ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val}) | |
6988 | 26 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) |
7650 | 27 ## @deftypefnx {Function File} {@var{h} =} patch (@dots{}) |
6895 | 28 ## Create patch object from @var{x} and @var{y} with color @var{c} and |
29 ## insert in the current axes object. Return handle to patch object. | |
30 ## | |
31 ## For a uniform colored patch, @var{c} can be given as an RGB vector, | |
32 ## scalar value referring to the current colormap, or string value (for | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
33 ## example, "r" or "red"). |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
34 ## |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
35 ## If passed a structure @var{fv} contain the fields "vertices", "faces" |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
36 ## and optionally "facevertexcdata", create the patch based on these |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
37 ## properties. |
6807 | 38 ## @end deftypefn |
39 | |
40 ## Author: jwe | |
41 | |
7216 | 42 function retval = patch (varargin) |
6807 | 43 |
7215 | 44 [h, varargin] = __plt_get_axis_arg__ ("patch", varargin{:}); |
7216 | 45 |
13802
630d3c80b541
allow axes handle to be passed to patch function
John W. Eaton <jwe@octave.org>
parents:
13299
diff
changeset
|
46 [tmp, failed] = __patch__ (h, varargin{:}); |
7216 | 47 |
13802
630d3c80b541
allow axes handle to be passed to patch function
John W. Eaton <jwe@octave.org>
parents:
13299
diff
changeset
|
48 if (failed) |
630d3c80b541
allow axes handle to be passed to patch function
John W. Eaton <jwe@octave.org>
parents:
13299
diff
changeset
|
49 print_usage (); |
630d3c80b541
allow axes handle to be passed to patch function
John W. Eaton <jwe@octave.org>
parents:
13299
diff
changeset
|
50 endif |
7020 | 51 |
6807 | 52 if (nargout > 0) |
7216 | 53 retval = tmp; |
6807 | 54 endif |
55 | |
56 endfunction | |
7020 | 57 |
58 %!demo | |
59 %! ## Patches with same number of vertices | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
60 %! clf |
7020 | 61 %! t1 = (1/16:1/8:1)'*2*pi; |
62 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
63 %! x1 = sin(t1) - 0.8; | |
64 %! y1 = cos(t1); | |
65 %! x2 = sin(t2) + 0.8; | |
66 %! y2 = cos(t2); | |
67 %! patch([x1,x2],[y1,y2],'r'); | |
68 | |
69 %!demo | |
70 %! ## Unclosed patch | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
71 %! clf |
7020 | 72 %! t1 = (1/16:1/8:1)'*2*pi; |
73 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
74 %! x1 = sin(t1) - 0.8; | |
75 %! y1 = cos(t1); | |
76 %! x2 = sin(t2) + 0.8; | |
77 %! y2 = cos(t2); | |
78 %! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r'); | |
79 | |
80 %!demo | |
81 %! ## Specify vertices and faces separately | |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
82 %! clf |
7020 | 83 %! t1 = (1/16:1/8:1)'*2*pi; |
84 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
85 %! x1 = sin(t1) - 0.8; | |
86 %! y1 = cos(t1); | |
87 %! x2 = sin(t2) + 0.8; | |
88 %! y2 = cos(t2); | |
89 %! vert = [x1, y1; x2, y2]; | |
90 %! fac = [1:8,NaN(1,8);9:24]; | |
91 %! patch('Faces',fac,'Vertices',vert,'FaceColor','r'); | |
92 | |
93 %!demo | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
94 %! ## Specify vertices and faces separately |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
95 %! clf |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
96 %! t1 = (1/16:1/8:1)'*2*pi; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
97 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
98 %! x1 = sin(t1) - 0.8; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
99 %! y1 = cos(t1); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
100 %! x2 = sin(t2) + 0.8; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
101 %! y2 = cos(t2); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
102 %! vert = [x1, y1; x2, y2]; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
103 %! fac = [1:8,NaN(1,8);9:24]; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
104 %! patch('Faces',fac,'Vertices',vert,'FaceVertexCData', [0, 1, 0; 0, 0, 1]); |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
105 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
106 %!demo |
7020 | 107 %! ## Property change on multiple patches |
8790
a013ff655ca4
Trivial changes to demos to produce a more pleasant output for octave+gnuplot+aquaterm.
Ben Abbott <bpabbott@mac.com>
parents:
7650
diff
changeset
|
108 %! clf |
7020 | 109 %! t1 = (1/16:1/8:1)'*2*pi; |
110 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
111 %! x1 = sin(t1) - 0.8; | |
112 %! y1 = cos(t1); | |
113 %! x2 = sin(t2) + 0.8; | |
114 %! y2 = cos(t2); | |
115 %! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); | |
116 %! pause (1); | |
117 %! set (h, 'FaceColor', 'r'); | |
9110
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
118 |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
119 %!demo |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
120 %! clf |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
121 %! vertices = [0, 0, 0; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
122 %! 1, 0, 0; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
123 %! 1, 1, 0; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
124 %! 0, 1, 0; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
125 %! 0.5, 0.5, 1]; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
126 %! faces = [1, 2, 5; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
127 %! 2, 3, 5; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
128 %! 3, 4, 5; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
129 %! 4, 1, 5]; |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
130 %! patch('Vertices', vertices, 'Faces', faces, ... |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
131 %! 'FaceVertexCData', jet(4), 'FaceColor', 'flat') |
22ae6b3411a7
Add isocolor, isonormals and isosurface functions (For Martin Helm). Add 3D filled triangular patches and the trisurf function
David Bateman <dbateman@free.fr>
parents:
8920
diff
changeset
|
132 %! view (-37.5, 30) |
12533 | 133 |
134 %!demo | |
135 %! clf | |
136 %! vertices = [0, 0, 0; | |
137 %! 1, 0, 0; | |
138 %! 1, 1, 0; | |
139 %! 0, 1, 0; | |
140 %! 0.5, 0.5, 1]; | |
141 %! faces = [1, 2, 5; | |
142 %! 2, 3, 5; | |
143 %! 3, 4, 5; | |
144 %! 4, 1, 5]; | |
145 %! patch('Vertices', vertices, 'Faces', faces, ... | |
146 %! 'FaceVertexCData', jet(5), 'FaceColor', 'interp') | |
147 %! view (-37.5, 30) | |
148 | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
149 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
150 %! clf |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
151 %! colormap (jet) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
152 %! x = [0 1 1 0]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
153 %! y = [0 0 1 1]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
154 %! subplot (2, 1, 1) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
155 %! title ("Blue, Light-Green, and Red Horizontal Bars") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
156 %! patch (x, y + 0, 1); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
157 %! patch (x, y + 1, 2); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
158 %! patch (x, y + 2, 3); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
159 %! subplot (2, 1, 2) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
160 %! title ("Blue, Light-Green, and Red Vertical Bars") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
161 %! patch (x + 0, y, 1 * ones (size (x))); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
162 %! patch (x + 1, y, 2 * ones (size (x))); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
163 %! patch (x + 2, y, 3 * ones (size (x))); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
164 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
165 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
166 %! clf |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
167 %! colormap (jet) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
168 %! x = [0 1 1 0]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
169 %! y = [0 0 1 1]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
170 %! subplot (2, 1, 1) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
171 %! title ("Blue horizontal bars: Dark to Light") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
172 %! patch (x, y + 0, 1, "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
173 %! patch (x, y + 1, 9, "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
174 %! patch (x, y + 2, 17, "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
175 %! subplot (2, 1, 2) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
176 %! title ("Blue vertical bars: Dark to Light") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
177 %! patch (x + 0, y, 1 * ones (size (x)), "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
178 %! patch (x + 1, y, 9 * ones (size (x)), "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
179 %! patch (x + 2, y, 17 * ones (size (x)), "cdatamapping", "direct"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
180 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
181 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
182 %! clf; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
183 %! colormap (jet); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
184 %! x = [ 0 0; 1 1; 1 0 ]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
185 %! y = [ 0 0; 0 1; 1 1 ]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
186 %! p = patch (x, y, "facecolor", "b"); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
187 %! title ("Two blue triangles") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
188 %! set (p, "cdatamapping", "direct", "facecolor", "flat", "cdata", [1 32]) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
189 %! title ("Direct mapping of colors: Light-Green UL and Blue LR triangles") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
190 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
191 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
192 %! clf; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
193 %! colormap (jet); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
194 %! x = [ 0 0; 1 1; 1 0 ]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
195 %! y = [ 0 0; 0 1; 1 1 ]; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
196 %! p = patch (x, y, [1 32]); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
197 %! title ("Autoscaling of colors: Red UL and Blue LR triangles") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
198 |
13115
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
199 %!test |
13124
2ea1658ad049
Don't use explicit figure number for tests to avoid interference with any figures opened by user.
Kai Habel <kai.habel@gmx.de>
parents:
13115
diff
changeset
|
200 %! hf = figure ("visible", "off"); |
13141
e81ddf9cacd5
maint: untabify and remove trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
13124
diff
changeset
|
201 %! unwind_protect |
13115
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
202 %! h = patch; |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
203 %! assert (findobj (hf, "type", "patch"), h); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
204 %! assert (get (h, "xdata"), [0; 1; 1], eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
205 %! assert (get (h, "ydata"), [0; 0; 1], eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
206 %! assert (isempty(get (h, "zdata"))); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
207 %! assert (isempty(get (h, "cdata"))); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
208 %! assert (get (h, "faces"), [1, 2, 3], eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
209 %! assert (get (h, "vertices"), [0 0; 1 0; 1 1], eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
210 %! assert (get (h, "type"), "patch"); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
211 %! assert (get (h, "facecolor"), [0 0 1]); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
212 %! assert (get (h, "linestyle"), get (0, "defaultpatchlinestyle")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
213 %! assert (get (h, "linewidth"), get (0, "defaultpatchlinewidth"), eps); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
214 %! assert (get (h, "marker"), get (0, "defaultpatchmarker")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
215 %! assert (get (h, "markersize"), get (0, "defaultpatchmarkersize")); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
216 %! unwind_protect_cleanup |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
217 %! close (hf); |
cd808de114c1
Allow surface and patch to be called w/o arguments. Adding and fixing tests.
Kai Habel <kai.habel@gmx.de>
parents:
12533
diff
changeset
|
218 %! end_unwind_protect |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
219 |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
220 %!test |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
221 %! hf = figure ("visible", "off"); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
222 %! c = 0.9; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
223 %! unwind_protect |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
224 %! h = patch ([0 1 0], [0 1 1], c); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
225 %! assert (get (gca, "clim"), [c - 1, c + 1]); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
226 %! h = patch ([0 1 0], [0 1 1], 2 * c); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
227 %! assert (get (gca, "clim"), [c, 2 * c]); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
228 %! unwind_protect_cleanup |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
229 %! close (hf); |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
230 %! end_unwind_protect |