changeset 6886:1c1d62569590

[project @ 2007-09-10 20:58:34 by jwe]
author jwe
date Mon, 10 Sep 2007 20:58:34 +0000
parents 987a7bf45c99
children 86e6cf1f998a
files scripts/plot/__bar__.m scripts/plot/__patch__.m
diffstat 2 files changed, 48 insertions(+), 45 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/plot/__bar__.m	Mon Sep 10 20:51:09 2007 +0000
+++ b/scripts/plot/__bar__.m	Mon Sep 10 20:58:34 2007 +0000
@@ -26,38 +26,39 @@
 ## Author: jwe
 
 function varargout = __bar__ (vertical, func, varargin)
+
   width = 0.8;
   group = true;
 
   if (nargin < 3)
-    print_usage();
+    print_usage ();
   endif
 
-  if (nargin > 3 && isnumeric(varargin{2}))
+  if (nargin > 3 && isnumeric (varargin{2}))
     x = varargin{1};
-    if (isvector(x))
+    if (isvector (x))
       x = x(:);
     endif
     y = varargin{2};
-    if (isvector(y))
+    if (isvector (y))
       y = y(:);
     endif
-    if (size(x,1) != size(y,1))
+    if (size (x, 1) != size (y, 1))
       y = varargin{1};
-      if (isvector(y))
+      if (isvector (y))
 	y = y(:);
       endif
       x = [1:size(y,1)]';
       idx = 2;
     else
-      if (! isvector(x))
+      if (! isvector (x))
 	error ("%s: x must be a vector", func);
       endif
       idx = 3;
     endif
   else
     y = varargin{1};
-    if (isvector(y))
+    if (isvector (y))
       y = y(:);
     endif
     x = [1:size(y,1)]';
@@ -65,19 +66,20 @@
   endif
       
   newargs = {};
-  HaveLineSpec = false;
+  have_line_spec = false;
   while (idx <= nargin -2)
-    if (isstr(varargin{idx}) && strcmp(varargin{idx},"grouped"))
+    if (isstr (varargin{idx}) && strcmp (varargin{idx}, "grouped"))
       group = true;
       idx++;
-    elseif (isstr(varargin{idx}) && strcmp(varargin{idx},"stacked"))
+    elseif (isstr (varargin{idx}) && strcmp (varargin{idx}, "stacked"))
       group = false;
       idx++;
     else
-      if ((isstr(varargin{idx}) || iscell(varargin{idx})) && !HaveLineSpec)
+      if ((isstr (varargin{idx}) || iscell (varargin{idx}))
+	  && ! have_line_spec)
 	[linespec, valid] = __pltopt__ (func, varargin{idx}, false);
 	if (valid)
-	  HaveLineSpec = true;
+	  have_line_spec = true;
 	  newargs = [{linespec.color}, newargs];
 	  idx++;
 	  continue;
@@ -114,7 +116,7 @@
   delta_m = [(cutoff(1) - x(1)); (x(2:end) - cutoff)] * width;
   x1 = (x - delta_m)(:)';
   x2 = (x + delta_p)(:)';
-  xb = repmat([x1; x1; x2; x2](:), 1, ycols);
+  xb = repmat ([x1; x1; x2; x2](:), 1, ycols);
 
   if (group)
     width = width / ycols;
@@ -139,7 +141,7 @@
   xb = reshape (xb, 4, numel (xb) /  4);
   yb = reshape (yb, 4, numel (yb) /  4);
 
-  if (! HaveLineSpec)
+  if (! have_line_spec)
     colors = [1, 0, 0; 0, 1, 0; 0, 0, 1; 1, 1, 0; 1, 0, 1; 0, 1, 1];
     newargs = [{shiftdim(colors (mod (floor ([0 : (ycols * ylen - 1)] / ylen), 
 				      6) + 1, :), -1)}, newargs];
@@ -163,6 +165,6 @@
       varargout{1} = yb;
       varargout{2} = xb;
     endif
-  endif    
+  endif
 
 endfunction
--- a/scripts/plot/__patch__.m	Mon Sep 10 20:51:09 2007 +0000
+++ b/scripts/plot/__patch__.m	Mon Sep 10 20:58:34 2007 +0000
@@ -33,28 +33,28 @@
 
   iarg = 1;
   have_x = have_z = have_c = false;
-  if (isnumeric (varargin {1}))
-    if (!isnumeric (varargin {2}))
+  if (isnumeric (varargin{1}))
+    if (! isnumeric (varargin{2}))
       print_usage ();
     endif
 
-    x = varargin {1};
-    y = varargin {2};
+    x = varargin{1};
+    y = varargin{2};
     have_x = true;
     iarg += 2;
 
-    if (nargin > 3 && ndims (varargin {3}) == 2 && 
-	size (varargin {3}) == size (x))
+    if (nargin > 3 && ndims (varargin{3}) == 2 && ndims (x) == 2
+	&& size (varargin{3}) == size (x))
       z = varargin {3};
       have_z = true;
-      iarg ++;
+      iarg++;
     endif
   endif
 
-  if (have_x && nargin > iarg && isnumeric (varargin {iarg}))
-    c = varargin {iarg};
+  if (have_x && nargin > iarg && isnumeric (varargin{iarg}))
+    c = varargin{iarg};
     have_c = true;
-    iarg ++;
+    iarg++;
 
     if (ndims (c) == 3 && size (c, 2) == 1)
       c = permute (c, [1, 3, 2]);
@@ -87,53 +87,53 @@
       endif
 
       if (have_c)
-	if (ndims (c) == 2 && ((nr > 3 && size (c, 2) == nc) ||
-			       (size (c, 1) > 1 && size (c, 2) == nc)))
+	if (ndims (c) == 2 && ((nr > 3 && size (c, 2) == nc)
+			       || (size (c, 1) > 1 && size (c, 2) == nc)))
 	  c2 = c (:, i);
 	elseif (ndims (c) == 3)
-	  c2 = permute (c (:, i, :), [1, 3, 2]);
+	  c2 = permute (c(:,i,:), [1, 3, 2]);
 	else
 	  c2 = c;
 	endif
 
 	if (numel (c2) == 1)
 	  if (isnan (c))
-	    set (h, "FaceColor", [1, 1, 1]);
-	    set (h, "CData", c2);
+	    set (h, "facecolor", [1, 1, 1]);
+	    set (h, "cdata", c2);
 	  elseif (isnumeric (c2))
 	    ## Have color index.
-	    set (h, "FaceColor", "flat");
-	    set (h, "CData", c2);
-	    clim = get(ax, "CLim");
+	    set (h, "facecolor", "flat");
+	    set (h, "cdata", c2);
+	    clim = get(ax, "clim");
 	    if (c2 < clim(1))
-              set (ax, "CLim", [c2, clim(2)])
+              set (ax, "clim", [c2, clim(2)])
 	    endif
 	    if (c2 > clim(2))
-              set (ax, "CLim", [clim(1), c2])
+              set (ax, "clim", [clim(1), c2])
 	    endif
 	  else
 	    ## Unknown color value.
-	    error ("color value not valid");
+	    error ("patch: color value not valid");
 	  endif
 	elseif (numel (c2) == 3)
 	  ## Have rgb/rgba value.
-	  set (h, "FaceColor", c2);
+	  set (h, "facecolor", c2);
 	else
 	  ## Color vector.
 	  if (length (c2) != length (x) || length (c2) != length (y))
-	    error ("size of x, y, and c must be equal")
+	    error ("patch: size of x, y, and c must be equal")
 	  else
-	    set (h, "FaceColor", "interp");
-	    set(h, "CData", c2);
+	    set (h, "facecolor", "interp");
+	    set(h, "cdata", c2);
 	    if (abs(max(c2) - min(c2)) < eps)
-              set (ax, "CLim", [c2(1)-1, c2(1)+1])
+              set (ax, "clim", [c2(1)-1, c2(1)+1])
 	    else
-              set (ax, "CLim", [min(c2), max(c2)]);
+              set (ax, "clim", [min(c2), max(c2)]);
 	    endif
 	  endif
 	endif
       else
-	set (h, "FaceColor", [0, 1, 0]);
+	set (h, "facecolor", [0, 1, 0]);
       endif
 
       if (nargin > iarg + 1)
@@ -141,6 +141,7 @@
       endif
     endfor
   else
-    error ("Not supported");
+    error ("patch: not supported");
   endif
+
 endfunction