# HG changeset patch # User Rik # Date 1544830704 28800 # Node ID 64061eace0578546c3dd3a7ba9886241c7468844 # Parent 71d618146e4c53b0c0950a28f4f349e1461ad632 legend.m: Implement "bestoutside" location. * legend.m: Use strcmp rather than switch statement to validate orientation. For "bestoutside" choose "northeastoutside" if orientation is vertical and "southoutside" if orientation is horizontal. diff -r 71d618146e4c -r 64061eace057 scripts/plot/appearance/legend.m --- a/scripts/plot/appearance/legend.m Fri Dec 14 13:39:15 2018 -0800 +++ b/scripts/plot/appearance/legend.m Fri Dec 14 15:38:24 2018 -0800 @@ -237,12 +237,9 @@ endwhile ## Validate the orientation - switch (orientation) - case {"vertical", "horizontal", "default"} - ## These are all accepted orientations. - otherwise - error ("legend: unrecognized legend orientation"); - endswitch + if (! any (strcmp (orientation, {"vertical", "horizontal", "default"}))) + error ("legend: unrecognized legend orientation"); + endif ## Validate the location type outside = false; @@ -257,11 +254,23 @@ switch (location) case {"north", "south", "east", "west", "northeast", "northwest", ... "southeast", "southwest", "default"} + ## These are all valid locations, do nothing. + case "best" - warning ("legend: 'best' not yet implemented for location specifier\n"); - location = "northeast"; + if (outside) + if (strcmp (orientation, "horizontal")) + location = "south"; + else + location = "northeast"; + endif + else + warning ("legend: 'best' not yet implemented for location specifier, using 'northeast' instead\n"); + location = "northeast"; + endif + case "none" ## FIXME: Should there be any more error checking on this? + otherwise error ("legend: unrecognized legend location"); endswitch