diff scripts/plot/legend.m @ 13216:434e227b100b

Improvements to plotyy. * scripts/plot/plotyy.m: Don't use "tag" or "userdata" manage plotyy axes. * scripts/plot/legend.m: Ditto. * scripts/plot/private/__go_draw_axes__.m: Ditto. * src/gl-render.cc: Ditto.
author Ben Abbott <bpabbott@mac.com>
date Sun, 25 Sep 2011 13:48:09 -0400
parents e81ddf9cacd5
children 984359717d71
line wrap: on
line diff
--- a/scripts/plot/legend.m
+++ b/scripts/plot/legend.m
@@ -119,13 +119,20 @@
     ca = gca ();
   endif
 
-  if (strcmp (get (ca, "tag"), "plotyy"))
-    plty = get(ca, "userdata");
-    if (isscalar (plty))
+  if (ishandle (ca) && isprop (ca, "__plotyy_axes__"))
+    plty = get (ca, "__plotyy_axes__");
+    if (isscalar (plty) && ishandle (plty))
       ca = [ca, plty];
-    else
+    elseif (iscell (plty))
       ca = [ca, plty{:}];
+    elseif (all (ishandle (plty)))
+      ca = [ca, plty(:).'];
+    else
+      error ("legend.m: This should not happen. File a bug report.")
     endif
+    ## Remove duplicates while preserving order
+    [~, n] = unique (ca);
+    ca = ca (sort (n));
   endif
 
   if (nargin > 0 && all (ishandle (varargin{1})))