Mercurial > hg > octave-lyh
diff scripts/plot/plot3.m @ 8078:4665276ff7f6
correctly plot matrices in plot3
author | David Bateman <dbateman@free.fr> |
---|---|
date | Tue, 02 Sep 2008 14:50:08 -0400 |
parents | a028a5960e18 |
children | 79c874fe5100 |
line wrap: on
line diff
--- 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]);