Mercurial > hg > octave-nkf
diff scripts/plot/plot3.m @ 10995:e81914f3921f
Update legend code to support fltk (fixes #29348 and partially fixes #30461)
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sat, 18 Sep 2010 22:30:41 +0200 |
parents | 95c3e38098bf |
children | fd0a3ac60b0e |
line wrap: on
line diff
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -95,7 +95,8 @@ property_set = 0; fmt_set = 0; properties = {}; - + tlgnd = {}; + hlgnd = []; idx = 0; ## Gather arguments, decode format, and plot lines. @@ -171,11 +172,6 @@ error ("plot3: x, y, and z must have the same shape"); endif - key = options.key; - if (! isempty (key)) - set (gca (), "key", "on"); - endif - for i = 1 : columns (x) linestyle = options.linestyle; marker = options.marker; @@ -183,13 +179,18 @@ [linestyle, marker] = __next_line_style__ (); endif color = options.color; - if (isempty (options.color)) + if (isempty (color)) color = __next_line_color__ (); endif - tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, + tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); + key = options.key; + if (! isempty (key)) + hlgnd = [hlgnd, tmp(idx)]; + tlgnd = {tlgnd{:}, key}; + endif endfor x_set = 0; @@ -224,11 +225,6 @@ endif options = __default_plot_options__ (); - key = options.key; - if (! isempty (key)) - set (gca (), "key", "on"); - endif - for i = 1 : columns (x) linestyle = options.linestyle; marker = options.marker; @@ -240,9 +236,14 @@ color = __next_line_color__ (); endif - tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, + tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); + key = options.key; + if (! isempty (key)) + hlgnd = [hlgnd, tmp(idx)]; + tlgnd = {tlgnd{:}, key}; + endif endfor x = new; @@ -296,10 +297,6 @@ endif options = __default_plot_options__ (); - key = options.key; - if (! isempty (key)) - set (gca (), "key", "on"); - endif for i = 1 : columns (x) linestyle = options.linestyle; @@ -312,12 +309,21 @@ color = __next_line_color__ (); endif - tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "keylabel", key, + tmp(++idx) = line (x(:, i), y(:, i), z(:, i), "color", color, "linestyle", linestyle, "marker", marker, properties{:}); + key = options.key; + if (! isempty (key)) + hlgnd = [hlgnd, tmp(idx)]; + tlgnd = {tlgnd{:}, key}; + endif endfor endif + if (!isempty (hlgnd)) + legend (gca(), hlgnd, tlgnd); + endif + set (gca (), "view", [-37.5, 30]); if (nargout > 0 && idx > 0)