octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 2.9.15 --> 3.0


From: Peter Gustafson
Subject: Re: 2.9.15 --> 3.0
Date: Sun, 07 Oct 2007 10:05:17 -0400
User-agent: Thunderbird 2.0.0.6 (X11/20070804)

John W. Eaton wrote:
> On  6-Oct-2007, Peter A. Gustafson wrote:
> 
> | I would like to see the legend command be fully compatible.  I tried a 
> patch 
> | earlier but I think it was missed... or perhaps the attempt at maintaining 
> | backwards compatibility with prior octave-forge legend wasn't appreciated? 
> :)  
> | Regardless, I've got it working locally (fully matlab compatible - dropped 
> | backwards to octave-forge).
> | 
> | Would you like the patch now or should it wait?
> 
> Please send the patch.
> 
> jwe

Attached.

Pete Gustafson


2007-10-07  Peter A. Gustafson  <address@hidden>

        * plot/__go_draw_axes__.m: ...
        * plot/legend.m: Updates required for compatibility.
        
Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /cvs/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.44
diff -u -r1.44 __go_draw_axes__.m
--- scripts/plot/__go_draw_axes__.m     5 Oct 2007 22:40:59 -0000       1.44
+++ scripts/plot/__go_draw_axes__.m     7 Oct 2007 14:02:04 -0000
@@ -755,9 +755,17 @@
        box = "nobox";
       endif
       inout = "inside";
-      switch (axis_obj.keypos)
+      keypos = axis_obj.keypos;
+      if (ischar (keypos))
+       keyout = findstr (keypos, "outside");
+       if (! isempty (keyout))
+         inout = "outside";
+         keypos = keypos (1:keyout-1);
+       endif
+      endif
+      switch (keypos)
        case -1
-         pos = "right bottom";
+         pos = "right top";
          inout = "outside";
        case 1
          pos = "right top";
@@ -765,8 +773,29 @@
          pos = "left top";
        case 3
          pos = "left bottom";
-       case 4
+       case {4, 0}
          pos = "right bottom";
+       case "north"
+         pos = "center top";
+       case "south"
+         pos = "center bottom";
+       case "east"
+         pos = "right center";
+       case "west"
+         pos = "left center";
+       case "northeast"
+         pos = "right top";
+       case "northwest"
+         pos = "left top";
+       case "southeast"
+         pos = "right bottom";
+       case "southwest"
+         pos = "left bottom";
+       case "best" 
+         pos = "";
+         warning ("legend: 'Best' not yet implemented for location 
specifier.\n");
+         ## least conflict with data in plot
+         ## least unused space outside plot
        otherwise
          pos = "";
       endswitch
Index: scripts/plot/legend.m
===================================================================
RCS file: /cvs/octave/scripts/plot/legend.m,v
retrieving revision 1.11
diff -u -r1.11 legend.m
--- scripts/plot/legend.m       13 Sep 2007 18:22:38 -0000      1.11
+++ scripts/plot/legend.m       7 Oct 2007 14:02:04 -0000
@@ -20,11 +20,11 @@
 
 ## -*- texinfo -*-
 ## @deftypefn {Function File} {} legend (@var{st1}, @var{st2}, @dots{})
-## @deftypefnx {Function File} {} legend (@var{st1}, @var{st2}, @dots{}, 
@var{pos})
+## @deftypefnx {Function File} {} legend (@var{st1}, @var{st2}, @dots{}, 
"location", @var{pos})
 ## @deftypefnx {Function File} {} legend (@var{matstr})
-## @deftypefnx {Function File} {} legend (@var{matstr}, @var{pos})
+## @deftypefnx {Function File} {} legend (@var{matstr}, "location", @var{pos})
 ## @deftypefnx {Function File} {} legend (@var{cell})
-## @deftypefnx {Function File} {} legend (@var{cell}, @var{pos})
+## @deftypefnx {Function File} {} legend (@var{cell}, "location", @var{pos})
 ## @deftypefnx {Function File} {} legend ('@var{func}')
 ##
 ## Display a legend for the current axes using the specified strings
@@ -36,19 +36,26 @@
 ## The optional parameter @var{pos} specifies the location of the legend
 ## as follows:
 ##
-## @multitable @columnfractions 0.1 0.1 0.8
-## @item @tab -1 @tab
-##   To the top right of the plot
-## @item @tab 0 @tab
-##   Don't move the legend box (default)
-## @item @tab 1 @tab
-##   Upper right-hand corner
-## @item @tab 2 @tab
-##   Upper left-hand corner
-## @item @tab 3 @tab
-##   Lower left-hand corner
-## @item @tab 4 @tab
-##   Lower right-hand corner
+## @multitable @columnfractions 0.06 0.14 0.80
+## @item @tab north @tab
+##   center top
+## @item @tab south @tab
+##   center bottom
+## @item @tab east @tab
+##   right center
+## @item @tab west @tab
+##   left center
+## @item @tab northeast @tab
+##   right top (default)
+## @item @tab northwest @tab
+##   left top
+## @item @tab southeast @tab
+##   right bottom
+## @item @tab southwest @tab
+##   left bottom
+## @item 
+## @item @tab outside @tab
+##   can be appended to any location string
 ## @end multitable
 ##
 ## Some specific functions are directely avaliable using @var{func}:
@@ -89,6 +96,15 @@
       endif
     endif
   endif
+  
+  if (nargs > 1)
+    pos = varargin{nargs-1};
+    str = lower (varargin{nargs});
+    if (strcmpi (pos, "location")  &&  ischar(str))
+      set (ca, "keypos", str);
+      nargs = nargs - 2;
+    endif
+  endif
 
   kids = get (ca, "children");
   nkids = numel (kids);
@@ -183,7 +199,7 @@
 %! close all;
 %! plot(1:10, 1:10);
 %! title("a very long label can sometimes cause problems");
-%! legend({"hello world"}, -1)
+%! legend({"hello world"}, "location", "northeastoutside")
 
 %!demo
 %! close all;
@@ -194,5 +210,5 @@
 %! endfor; hold off;
 %! title("Signals with random offset and uniform noise")
 %! xlabel("Sample Nr [k]"); ylabel("Amplitude [V]");
-%! legend(labels, -1)
+%! legend(labels, "location", "southoutside")
 %! legend("boxon")

reply via email to

[Prev in Thread] Current Thread [Next in Thread]