# HG changeset patch # User David Bateman # Date 1220381408 14400 # Node ID 4665276ff7f618f116d95c995fd27c30e45da7c7 # Parent a4e03f9b4b8ad5926df241e267861c27a0573e87 correctly plot matrices in plot3 diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2008-09-02 David Bateman + + * plot/__line__.m: Remove empty clause fof if/then/else test + * plot/plot3.m: Correctly plot matrices. + 2008-08-31 Michael Goffioul * plot/__plt2mm__.m, plot/__plt2mv__.m, plot/__plt2ss__.m, diff --git a/scripts/plot/__line__.m b/scripts/plot/__line__.m --- a/scripts/plot/__line__.m +++ b/scripts/plot/__line__.m @@ -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 diff --git a/scripts/plot/plot3.m b/scripts/plot/plot3.m --- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -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]);