# HG changeset patch # User David Bateman # Date 1297033177 -3600 # Node ID 735e43b75e456b54ddfbce9a7714a782fa950746 # Parent c60eaf7dac31b6f53305ae115173e39e63412bf8 Allow the legend location and orientation to be set without modifying the legend keys (#32374) diff -r c60eaf7dac31 -r 735e43b75e45 scripts/ChangeLog --- a/scripts/ChangeLog Sun Feb 06 23:29:16 2011 +0100 +++ b/scripts/ChangeLog Sun Feb 06 23:59:37 2011 +0100 @@ -1,5 +1,7 @@ 2011-02-05 David Bateman + * plot/legend.m: Allow the location and orientation to be set without + modifiying the legend keys. * plot/legend.m: Add padding to legend positions. Fix for outerposition for southeastoutside and southwestoutside. diff -r c60eaf7dac31 -r 735e43b75e45 scripts/plot/legend.m --- a/scripts/plot/legend.m Sun Feb 06 23:29:16 2011 +0100 +++ b/scripts/plot/legend.m Sun Feb 06 23:59:37 2011 +0100 @@ -288,6 +288,31 @@ if (! isempty (hlegend)) set (hlegend, "box", "off", "visible", "off"); endif + elseif (nargs == 0 && !(strcmp (position, "default") && + strcmp (orientation, "default"))) + if (! isempty (hlegend)) + hax = getfield (get (hlegend, "userdata"), "handle"); + [hplots, text_strings] = __getlegenddata__ (hlegend); + + if (strcmp (position, "default")) + h = legend (hax, hplots, text_strings, "orientation", orientation); + elseif (strcmp (orientation, "default")) + if (outside) + h = legend (hax, hplots, text_strings, "location", + strcat (position, "outside")); + else + h = legend (hax, hplots, text_strings, "location", position); + endif + else + if (outside) + h = legend (hax, hplots, text_strings, "location", + strcat (position, "outside"), "orientation", orientation); + else + h = legend (hax, hplots, text_strings, "location", position, + "orientation", orientation); + endif + endif + endif else hobjects = []; hplots = [];