comparison scripts/plot/__quiver__.m @ 7191:b48a21816f2e

[project @ 2007-11-26 21:24:32 by jwe]
author jwe
date Mon, 26 Nov 2007 21:24:33 +0000
parents e8d953d03f6a
children aa5208636bea
comparison
equal deleted inserted replaced
7190:9e7377f41b78 7191:b48a21816f2e
17 ## <http://www.gnu.org/licenses/>. 17 ## <http://www.gnu.org/licenses/>.
18 18
19 ## Undocumented internal function 19 ## Undocumented internal function
20 20
21 function hlist = __quiver__ (varargin) 21 function hlist = __quiver__ (varargin)
22 h = varargin {1}; 22
23 is3d = varargin {2}; 23 h = varargin{1};
24 is3d = varargin{2};
24 25
25 s = 1; 26 s = 1;
26 arrowsize = 0.33; 27 arrowsize = 0.33;
27 28
28 firstnonnumeric = Inf; 29 firstnonnumeric = Inf;
29 for i = 3:nargin 30 for i = 3:nargin
30 if (! isnumeric (varargin {i})) 31 if (! isnumeric (varargin{i}))
31 firstnonnumeric = i; 32 firstnonnumeric = i;
32 break; 33 break;
33 endif 34 endif
34 endfor 35 endfor
35 36
41 w = varargin{ioff++} 42 w = varargin{ioff++}
42 [x, y, z] = meshgrid (1:size(u,1), 1:size(u,2), 1:max(size(w))); 43 [x, y, z] = meshgrid (1:size(u,1), 1:size(u,2), 1:max(size(w)));
43 else 44 else
44 [x, y] = meshgrid (1:size(u,1), 1:size(u,2)); 45 [x, y] = meshgrid (1:size(u,1), 1:size(u,2));
45 endif 46 endif
46 if (nargin >= ioff && isnumeric (varargin{ioff}) && 47 if (nargin >= ioff && isnumeric (varargin{ioff})
47 isscalar (varargin{ioff})) 48 && isscalar (varargin{ioff}))
48 s = varargin{ioff++}; 49 s = varargin{ioff++};
49 endif 50 endif
50 else 51 else
51 x = varargin{ioff++}; 52 x = varargin{ioff++};
52 y = varargin{ioff++}; 53 y = varargin{ioff++};
55 endif 56 endif
56 u = varargin{ioff++}; 57 u = varargin{ioff++};
57 v = varargin{ioff++}; 58 v = varargin{ioff++};
58 if (is3d) 59 if (is3d)
59 w = varargin{ioff++}; 60 w = varargin{ioff++};
60 if (isvector(x) && isvector(y) && isvector(z) && 61 if (isvector (x) && isvector (y) && isvector (z)
61 (!isvector (u) || !isvector (v) || !isvector(w))) 62 && (! isvector (u) || ! isvector (v) || ! isvector(w)))
62 [x, y, z] = meshgrid (x, y, z); 63 [x, y, z] = meshgrid (x, y, z);
63 endif 64 endif
64 else 65 else
65 if (isvector(x) && isvector(y) && (!isvector (u) || !isvector (v))) 66 if (isvector (x) && isvector (y) && (! isvector (u) || ! isvector (v)))
66 [x, y] = meshgrid (x, y); 67 [x, y] = meshgrid (x, y);
67 endif 68 endif
68 endif 69 endif
69 if (nargin >= ioff && isnumeric (varargin{ioff}) && 70 if (nargin >= ioff && isnumeric (varargin{ioff})
70 isscalar (varargin{ioff})) 71 && isscalar (varargin{ioff}))
71 s = varargin{ioff++}; 72 s = varargin{ioff++};
72 endif 73 endif
73 endif 74 endif
74 75
75 have_filled = false; 76 have_filled = false;
76 have_line_spec = false; 77 have_line_spec = false;
77 while (ioff <= nargin) 78 while (ioff <= nargin)
78 arg = varargin {ioff++}; 79 arg = varargin{ioff++};
79 if (ischar (arg) && strncmp (tolower (arg), "filled", 6)) 80 if (ischar (arg) && strncmp (tolower (arg), "filled", 6))
80 have_filled = true; 81 have_filled = true;
81 elseif ((isstr (arg) || iscell (arg)) 82 elseif ((isstr (arg) || iscell (arg))
82 && ! have_line_spec) 83 && ! have_line_spec)
83 [linespec, valid] = __pltopt__ ("quiver", arg, false); 84 [linespec, valid] = __pltopt__ ("quiver", arg, false);
192 else 193 else
193 h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:), 194 h2 = plot ([xarrw1.'; xend.'; xarrw2.'; NaN(1, length (x))](:),
194 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:)); 195 [yarrw1.'; yend.'; yarrw2.'; NaN(1, length (y))](:));
195 endif 196 endif
196 197
197 if (! have_line_spec || (isfield (linespec, "marker") && 198 if (! have_line_spec
198 strncmp (linespec.marker, "none", 4))) 199 || (isfield (linespec, "marker")
200 && strncmp (linespec.marker, "none", 4)))
199 if (is3d) 201 if (is3d)
200 h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none"); 202 h3 = plot3 (x, y, z, "linestyle", "none", "marker", "none");
201 else 203 else
202 h3 = plot (x, y, "linestyle", "none", "marker", "none"); 204 h3 = plot (x, y, "linestyle", "none", "marker", "none");
203 endif 205 endif
209 h3 = plot (x, y, "linestyle", "none", "marker", linespec.marker); 211 h3 = plot (x, y, "linestyle", "none", "marker", linespec.marker);
210 endif 212 endif
211 endif 213 endif
212 if (have_filled) 214 if (have_filled)
213 ## FIXME gnuplot doesn't respect the markerfacecolor field 215 ## FIXME gnuplot doesn't respect the markerfacecolor field
214 set(h3, "markerfacecolor", get (h1, "color")); 216 set (h3, "markerfacecolor", get (h1, "color"));
215 endif 217 endif
216 unwind_protect_cleanup 218 unwind_protect_cleanup
217 set (h, "nextplot", hstate); 219 set (h, "nextplot", hstate);
218 end_unwind_protect 220 end_unwind_protect
219 221