Mercurial > hg > octave-nkf
annotate scripts/plot/patch.m @ 13299:e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
* scripts/plot/patch.m: Add demos.
* scripts/plot/private/__patch__.m: Improvements to input parsing.
* scripts/plot/__go_draw_axes__.m: Accommodate patches with one scalar color
per vertex.
author | Ben Abbott <bpabbott@mac.com> |
---|---|
date | Sat, 08 Oct 2011 17:34:15 -0400 |
parents | e36c2f4ea8f5 |
children | 630d3c80b541 |
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 |
7215 | 46 oldh = gca (); |
7216 | 47 |
7215 | 48 unwind_protect |
49 axes (h); | |
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
|
50 [tmp, failed] = __patch__ (h, varargin{:}); |
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
|
51 if (failed) |
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
|
52 print_usage (); |
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
|
53 endif |
7215 | 54 unwind_protect_cleanup |
55 axes (oldh); | |
56 end_unwind_protect | |
7020 | 57 |
6807 | 58 if (nargout > 0) |
7216 | 59 retval = tmp; |
6807 | 60 endif |
61 | |
62 endfunction | |
7020 | 63 |
64 %!demo | |
65 %! ## 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
|
66 %! clf |
7020 | 67 %! t1 = (1/16:1/8:1)'*2*pi; |
68 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
69 %! x1 = sin(t1) - 0.8; | |
70 %! y1 = cos(t1); | |
71 %! x2 = sin(t2) + 0.8; | |
72 %! y2 = cos(t2); | |
73 %! patch([x1,x2],[y1,y2],'r'); | |
74 | |
75 %!demo | |
76 %! ## 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
|
77 %! clf |
7020 | 78 %! t1 = (1/16:1/8:1)'*2*pi; |
79 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
80 %! x1 = sin(t1) - 0.8; | |
81 %! y1 = cos(t1); | |
82 %! x2 = sin(t2) + 0.8; | |
83 %! y2 = cos(t2); | |
84 %! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r'); | |
85 | |
86 %!demo | |
87 %! ## 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
|
88 %! clf |
7020 | 89 %! t1 = (1/16:1/8:1)'*2*pi; |
90 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
91 %! x1 = sin(t1) - 0.8; | |
92 %! y1 = cos(t1); | |
93 %! x2 = sin(t2) + 0.8; | |
94 %! y2 = cos(t2); | |
95 %! vert = [x1, y1; x2, y2]; | |
96 %! fac = [1:8,NaN(1,8);9:24]; | |
97 %! patch('Faces',fac,'Vertices',vert,'FaceColor','r'); | |
98 | |
99 %!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
|
100 %! ## 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
|
101 %! 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
|
102 %! 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
|
103 %! 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
|
104 %! 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
|
105 %! 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
|
106 %! 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
|
107 %! 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
|
108 %! 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
|
109 %! 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
|
110 %! 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
|
111 |
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
|
112 %!demo |
7020 | 113 %! ## 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
|
114 %! clf |
7020 | 115 %! t1 = (1/16:1/8:1)'*2*pi; |
116 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
117 %! x1 = sin(t1) - 0.8; | |
118 %! y1 = cos(t1); | |
119 %! x2 = sin(t2) + 0.8; | |
120 %! y2 = cos(t2); | |
121 %! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); | |
122 %! pause (1); | |
123 %! 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
|
124 |
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 %!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
|
126 %! 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
|
127 %! 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
|
128 %! 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
|
129 %! 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
|
130 %! 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
|
131 %! 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
|
132 %! 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
|
133 %! 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
|
134 %! 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
|
135 %! 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
|
136 %! 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
|
137 %! '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
|
138 %! view (-37.5, 30) |
12533 | 139 |
140 %!demo | |
141 %! clf | |
142 %! vertices = [0, 0, 0; | |
143 %! 1, 0, 0; | |
144 %! 1, 1, 0; | |
145 %! 0, 1, 0; | |
146 %! 0.5, 0.5, 1]; | |
147 %! faces = [1, 2, 5; | |
148 %! 2, 3, 5; | |
149 %! 3, 4, 5; | |
150 %! 4, 1, 5]; | |
151 %! patch('Vertices', vertices, 'Faces', faces, ... | |
152 %! 'FaceVertexCData', jet(5), 'FaceColor', 'interp') | |
153 %! view (-37.5, 30) | |
154 | |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
155 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
156 %! clf |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
157 %! colormap (jet) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
158 %! 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
|
159 %! 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
|
160 %! subplot (2, 1, 1) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
161 %! 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
|
162 %! 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
|
163 %! 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
|
164 %! 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
|
165 %! subplot (2, 1, 2) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
166 %! 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
|
167 %! 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
|
168 %! 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
|
169 %! 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
|
170 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
171 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
172 %! clf |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
173 %! colormap (jet) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
174 %! 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
|
175 %! 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
|
176 %! subplot (2, 1, 1) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
177 %! 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
|
178 %! 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
|
179 %! 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
|
180 %! 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
|
181 %! subplot (2, 1, 2) |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
182 %! 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
|
183 %! 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
|
184 %! 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
|
185 %! 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
|
186 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
187 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
188 %! clf; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
189 %! colormap (jet); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
190 %! 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
|
191 %! 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
|
192 %! 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
|
193 %! title ("Two blue triangles") |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
194 %! 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
|
195 %! 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
|
196 |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
197 %!demo |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
198 %! clf; |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
199 %! colormap (jet); |
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
200 %! 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
|
201 %! 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
|
202 %! 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
|
203 %! 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
|
204 |
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
|
205 %!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
|
206 %! 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
|
207 %! 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
|
208 %! 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
|
209 %! 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
|
210 %! 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
|
211 %! 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
|
212 %! 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
|
213 %! 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
|
214 %! 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
|
215 %! 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
|
216 %! 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
|
217 %! 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
|
218 %! 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
|
219 %! 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
|
220 %! 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
|
221 %! 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
|
222 %! 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
|
223 %! 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
|
224 %! end_unwind_protect |
13247
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
225 |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
226 %!test |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
227 %! hf = figure ("visible", "off"); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
228 %! c = 0.9; |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
229 %! unwind_protect |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
230 %! 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
|
231 %! 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
|
232 %! 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
|
233 %! assert (get (gca, "clim"), [c, 2 * c]); |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
234 %! unwind_protect_cleanup |
e36c2f4ea8f5
Set clim correctly for patch objects:
Kai Habel <kai.habel@gmx.de>
parents:
13141
diff
changeset
|
235 %! close (hf); |
13299
e9f6a6edec42
Improvements to patch() and fix for bugs reported in #34417.
Ben Abbott <bpabbott@mac.com>
parents:
13247
diff
changeset
|
236 %! end_unwind_protect |