Mercurial > hg > octave-lyh
comparison scripts/plot/patch.m @ 7020:e31f12bb9194
[project @ 2007-10-13 05:13:28 by dbateman]
author | dbateman |
---|---|
date | Sat, 13 Oct 2007 05:13:29 +0000 |
parents | a1dbe9d80eee |
children | 121841c08c25 |
comparison
equal
deleted
inserted
replaced
7019:4270ded9ddc6 | 7020:e31f12bb9194 |
---|---|
18 | 18 |
19 ## -*- texinfo -*- | 19 ## -*- texinfo -*- |
20 ## @deftypefn {Function File} {} patch () | 20 ## @deftypefn {Function File} {} patch () |
21 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) | 21 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}) |
22 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}, @var{opts}) | 22 ## @deftypefnx {Function File} {} patch (@var{x}, @var{y}, @var{c}, @var{opts}) |
23 ## @deftypefnx {Function File} {} patch ('Faces', @var{f}, 'Vertices', @var{v}, @dots{}) | |
24 ## @deftypefnx {Function File} {} patch (@dots{}, @var{prop}, @var{val}) | |
23 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) | 25 ## @deftypefnx {Function File} {} patch (@var{h}, @dots{}) |
26 ## @deftypefnx {Function File} {@var{h} = } patch (@dots{}) | |
24 ## Create patch object from @var{x} and @var{y} with color @var{c} and | 27 ## Create patch object from @var{x} and @var{y} with color @var{c} and |
25 ## insert in the current axes object. Return handle to patch object. | 28 ## insert in the current axes object. Return handle to patch object. |
26 ## | 29 ## |
27 ## For a uniform colored patch, @var{c} can be given as an RGB vector, | 30 ## For a uniform colored patch, @var{c} can be given as an RGB vector, |
28 ## scalar value referring to the current colormap, or string value (for | 31 ## scalar value referring to the current colormap, or string value (for |
39 error ("patch: expecting first argument to be an axes object"); | 42 error ("patch: expecting first argument to be an axes object"); |
40 endif | 43 endif |
41 oldh = gca (); | 44 oldh = gca (); |
42 unwind_protect | 45 unwind_protect |
43 axes (h); | 46 axes (h); |
44 tmp = __patch__ (h, varargin{:}); | 47 [tmp, fail] = __patch__ (h, varargin{:}); |
45 unwind_protect_cleanup | 48 unwind_protect_cleanup |
46 axes (oldh); | 49 axes (oldh); |
47 end_unwind_protect | 50 end_unwind_protect |
48 else | 51 else |
49 tmp = __patch__ (gca (), varargin{:}); | 52 [tmp, fail] = __patch__ (gca (), varargin{:}); |
53 endif | |
54 | |
55 if (fail) | |
56 print_usage (); | |
50 endif | 57 endif |
51 | 58 |
52 if (nargout > 0) | 59 if (nargout > 0) |
53 h = tmp; | 60 h = tmp; |
54 endif | 61 endif |
55 | 62 |
56 endfunction | 63 endfunction |
64 | |
65 %!demo | |
66 %! ## Patches with same number of vertices | |
67 %! close all; | |
68 %! t1 = (1/16:1/8:1)'*2*pi; | |
69 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
70 %! x1 = sin(t1) - 0.8; | |
71 %! y1 = cos(t1); | |
72 %! x2 = sin(t2) + 0.8; | |
73 %! y2 = cos(t2); | |
74 %! patch([x1,x2],[y1,y2],'r'); | |
75 | |
76 %!demo | |
77 %! ## Unclosed patch | |
78 %! close all; | |
79 %! t1 = (1/16:1/8:1)'*2*pi; | |
80 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
81 %! x1 = sin(t1) - 0.8; | |
82 %! y1 = cos(t1); | |
83 %! x2 = sin(t2) + 0.8; | |
84 %! y2 = cos(t2); | |
85 %! patch([[x1;NaN(8,1)],x2],[[y1;NaN(8,1)],y2],'r'); | |
86 | |
87 %!demo | |
88 %! ## Specify vertices and faces separately | |
89 %! close all; | |
90 %! t1 = (1/16:1/8:1)'*2*pi; | |
91 %! t2 = ((1/16:1/16:1)' + 1/32)*2*pi; | |
92 %! x1 = sin(t1) - 0.8; | |
93 %! y1 = cos(t1); | |
94 %! x2 = sin(t2) + 0.8; | |
95 %! y2 = cos(t2); | |
96 %! vert = [x1, y1; x2, y2]; | |
97 %! fac = [1:8,NaN(1,8);9:24]; | |
98 %! patch('Faces',fac,'Vertices',vert,'FaceColor','r'); | |
99 | |
100 %!demo | |
101 %! ## Property change on multiple patches | |
102 %! close all; | |
103 %! t1 = (1/16:1/8:1)'*2*pi; | |
104 %! t2 = ((1/16:1/8:1)' + 1/32)*2*pi; | |
105 %! x1 = sin(t1) - 0.8; | |
106 %! y1 = cos(t1); | |
107 %! x2 = sin(t2) + 0.8; | |
108 %! y2 = cos(t2); | |
109 %! h = patch([x1,x2],[y1,y2],cat (3,[0,0],[1,0],[0,1])); | |
110 %! pause (1); | |
111 %! set (h, 'FaceColor', 'r'); |