changeset 8078:4665276ff7f6

correctly plot matrices in plot3
author David Bateman <dbateman@free.fr>
date Tue, 02 Sep 2008 14:50:08 -0400
parents a4e03f9b4b8a
children 082fa7859574
files scripts/ChangeLog scripts/plot/__line__.m scripts/plot/plot3.m
diffstat 3 files changed, 69 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sun Aug 31 11:14:34 2008 -0400
+++ b/scripts/ChangeLog	Tue Sep 02 14:50:08 2008 -0400
@@ -1,3 +1,8 @@
+2008-09-02  David Bateman  <dbateman@free.fr>
+
+	* plot/__line__.m: Remove empty clause fof if/then/else test
+	* plot/plot3.m: Correctly plot matrices.
+
 2008-08-31  Michael Goffioul  <michael.goffioul@gmail.com>
 
 	* plot/__plt2mm__.m, plot/__plt2mv__.m, plot/__plt2ss__.m,
--- a/scripts/plot/__line__.m	Sun Aug 31 11:14:34 2008 -0400
+++ b/scripts/plot/__line__.m	Tue Sep 02 14:50:08 2008 -0400
@@ -42,8 +42,7 @@
     num_data_args = 0;
   endif
 
-  if (rem (nvargs - num_data_args, 2) == 0)
-  else
+  if (rem (nvargs - num_data_args, 2) != 0)
     print_usage ("line");
   endif
 
--- a/scripts/plot/plot3.m	Sun Aug 31 11:14:34 2008 -0400
+++ b/scripts/plot/plot3.m	Tue Sep 02 14:50:08 2008 -0400
@@ -161,9 +161,9 @@
 	  y = y(:);
 	  z = z(:);
 	elseif (length (x) == rows (z) && length (y) == columns (z))
-	  error ("plot3: [length(x), length(y)] must match size(z)");
+	  [x, y] = meshgrid (x, y);
 	else
-	  [x, y] = meshgrid (x, y);
+	  error ("plot3: [length(x), length(y)] must match size(z)");
 	endif
       endif
 
@@ -175,22 +175,28 @@
       if (! isempty (key))
 	set (gca (), "key", "on");
       endif
-      color = options.color;
-      if (isempty (options.color))
-	color = __next_line_color__ ();
-      endif
+
+      for i = 1 : columns (x)
+	color = options.color;
+	if (isempty (options.color))
+	  color = __next_line_color__ ();
+	endif
+
+	hg = hggroup ();
+	tmp(++idx) = hg;
+	properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
 
-      hg = hggroup ();
-      tmp(++idx) = hg;
-      properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+	hline = line (x(:, i), y(:, i), z(:, i),  "keylabel", key,
+		      "color", color,
+		      "linestyle", options.linestyle,
+		      "marker", options.marker, "parent", hg);
 
-      hline = line (x(:), y(:), z(:),  "keylabel", key, "color", color,
-		    "linestyle", options.linestyle,
-		    "marker", options.marker, "parent", hg);
+	__add_line_series__ (hline, hg);
 
-      __add_line_series__ (hline, hg);
-
-      set (hg, properties{:});
+	if (! isempty (properties))
+	  set (hg, properties{:});
+	endif
+      endfor
 
       x_set = 0;
       y_set = 0;
@@ -213,9 +219,9 @@
 	  y = y(:);
 	  z = z(:);
 	elseif (length (x) == rows (z) && length (y) == columns (z))
-	  error ("plot3: [length(x), length(y)] must match size(z)");
+	  [x, y] = meshgrid (x, y);
 	else
-	  [x, y] = meshgrid (x, y);
+	  error ("plot3: [length(x), length(y)] must match size(z)");
 	endif
       endif
 
@@ -228,22 +234,28 @@
       if (! isempty (key))
 	set (gca (), "key", "on");
       endif
-      color = options.color;
-      if (isempty (color))
-	color = __next_line_color__ ();
-      endif
+
+      for i = 1 : columns (x)
+	color = options.color;
+	if (isempty (color))
+	  color = __next_line_color__ ();
+	endif
+
+	hg = hggroup ();
+	tmp(++idx) = hg;
+	properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
 
-      hg = hggroup ();
-      tmp(++idx) = hg;
-      properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+	hline = line (x(:, i), y(:, i), z(:, i),  "keylabel", key,
+		      "color", color,
+		      "linestyle", options.linestyle,
+		      "marker", options.marker, "parent", hg);
 
-      hline = line (x(:), y(:), z(:),  "keylabel", key, "color", color,
-		    "linestyle", options.linestyle,
-		    "marker", options.marker, "parent", hg);
+	__add_line_series__ (hline, hg);
 
-      __add_line_series__ (hline, hg);
-
-      set (hg, properties{:});
+	if (! isempty (properties))
+	  set (hg, properties{:});
+	endif
+      endfor
 
       x = new;
       y_set = 0;
@@ -285,9 +297,9 @@
 	y = y(:);
 	z = z(:);
       elseif (length (x) == rows (z) && length (y) == columns (z))
-	error ("plot3: [length(x), length(y)] must match size(z)");
+	[x, y] = meshgrid (x, y);
       else
-	[x, y] = meshgrid (x, y);
+	error ("plot3: [length(x), length(y)] must match size(z)");
       endif
     endif
 
@@ -300,21 +312,28 @@
     if (! isempty (key))
       set (gca (), "key", "on");
     endif
-    color = options.color;
-    if (isempty (color))
-      color = __next_line_color__ ();
-    endif
+
+    for i = 1 : columns (x)
+      color = options.color;
+      if (isempty (color))
+	color = __next_line_color__ ();
+      endif
+
+      hg = hggroup ();
+      tmp(++idx) = hg;
+      properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
 
-    hg = hggroup ();
-    tmp(++idx) = hg;
-    properties = __add_datasource__ ("plot3", hg, {"x", "y", "z"}, properties{:});
+      hline = line (x(:, i), y(:, i), z(:, i),  "keylabel", key, 
+		    "color", color,
+		    "linestyle", options.linestyle,
+		    "marker", options.marker, "parent", hg);
 
-    hline = line (x(:), y(:), z(:),  "keylabel", key, "color", color,
-		  "linestyle", options.linestyle,
-		  "marker", options.marker, "parent", hg);
+      __add_line_series__ (hline, hg);
 
-    __add_line_series__ (hline, hg);
-
+      if (! isempty (properties))
+	set (hg, properties{:});
+      endif
+    endfor
   endif
 
   set (gca (), "view", [-37.5, 30]);