# HG changeset patch # User Ben Abbott # Date 1326803406 18000 # Node ID 57e3490094e19d9a63d55028b087b05d1cc9cbdd # Parent df695e37d404885c0f6158c4acb942b05e2537c6 Fix order of legend entries for plotyy. Bug # 35314. * legend.m: Maintain the proper order of children for plotyy. Add demos. diff --git a/scripts/plot/legend.m b/scripts/plot/legend.m --- a/scripts/plot/legend.m +++ b/scripts/plot/legend.m @@ -147,7 +147,7 @@ if (isscalar (kids)) kids = get(kids, "children")(:); else - kids = [get(kids, "children"){:}](:); + kids = flipud ([get(kids, "children"){:}](:)); endif endif nargs = numel (varargin); @@ -1159,3 +1159,24 @@ %! h = legend ("Hello_World", "foo^bar"); %! set (h, "interpreter", "none") +%!demo +%! x = 0:10; +%! y1 = rand (size (x)); +%! y2 = rand (size (x)); +%! [ax, h1, h2] = plotyy (x, y1, x, y2); +%! legend ([h1, h2], {"Blue", "Green"}, "location", "south"); + +%!demo +%! x = 0:10; +%! y1 = rand (size (x)); +%! y2 = rand (size (x)); +%! [ax, h1, h2] = plotyy (x, y1, x, y2); +%! legend ({"Blue", "Green"}, "location", "south"); + +%!demo +%! x = 0:10; +%! y1 = rand (size (x)); +%! y2 = rand (size (x)); +%! [ax, h1, h2] = plotyy (x, y1, x, y2); +%! legend ("Blue", "Green", "location", "south"); +