octave-maintainers
[Top][All Lists]
Advanced

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

Legend order for vertical string cell.


From: Daniel J Sebald
Subject: Legend order for vertical string cell.
Date: Mon, 29 Dec 2008 20:53:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020

Ben,

This patch to the legend script:

http://hg.savannah.gnu.org/hgweb/octave/rev/9f34f7636fe0

fixed the case of horizontal string cells, but not vertical string cells.  Try 
something like:

x = [0:0.1:1]';
Y = [x sin(x)];
C = {'x', 'sine'};
plot(x, Y, '-');
legend(C);
pause;
C = {'x'; 'sinusoid'};
legend(C);

I've attached two patches to pick which way to fix this.  Either with a rot90() 
or indexing backward through the cell...  I suppose one should try

legend('x', 'sin(x)');

to make sure the order is also correct for non-cell entries.  (I don't have a 
recent version on this machine.)

Dan
diff -Pur octave/scripts/ChangeLog octave-mod/scripts/ChangeLog
--- octave/scripts/ChangeLog    2008-12-29 20:29:21.051889781 -0600
+++ octave-mod/scripts/ChangeLog        2008-12-29 20:32:49.626117605 -0600
@@ -1,5 +1,10 @@
 2008-12-29  David Bateman  <address@hidden>
 
+       * scripts/plot/legend.m: Fix legend order for both horizontal and
+       vertical string cell.
+
+2008-12-29  David Bateman  <address@hidden>
+
        * goemetry/voronoi.m: Speed up and handle dense grids.
 
 2008-12-28  Jaroslav Hajek <address@hidden>
diff -Pur octave/scripts/plot/legend.m octave-mod/scripts/plot/legend.m
--- octave/scripts/plot/legend.m        2008-12-29 20:27:25.102366880 -0600
+++ octave-mod/scripts/plot/legend.m    2008-12-29 20:33:18.015678775 -0600
@@ -165,13 +165,13 @@
        nargs = numel (varargin);
       endif
     elseif (iscellstr (arg))
-      varargin = fliplr (arg);
+      varargin = rot90 (arg, 2);
       nargs = numel (varargin);
     else
       error ("legend: expecting argument to be a character string");
     endif
   else
-    varargin(1:nargs) = fliplr (varargin(1:nargs));
+    varargin(1:nargs) = rot90 (varargin(1:nargs), 2);
   endif
 
   if (nargs > 0)
diff -Pur octave/scripts/ChangeLog octave-mod/scripts/ChangeLog
--- octave/scripts/ChangeLog    2008-12-29 20:29:21.051889781 -0600
+++ octave-mod/scripts/ChangeLog        2008-12-29 20:32:49.626117605 -0600
@@ -1,5 +1,10 @@
 2008-12-29  David Bateman  <address@hidden>
 
+       * scripts/plot/legend.m: Fix legend order for both horizontal and
+       vertical string cell.
+
+2008-12-29  David Bateman  <address@hidden>
+
        * goemetry/voronoi.m: Speed up and handle dense grids.
 
 2008-12-28  Jaroslav Hajek <address@hidden>
diff -Pur octave/scripts/plot/legend.m octave-mod/scripts/plot/legend.m
--- octave/scripts/plot/legend.m        2008-12-29 20:27:25.102366880 -0600
+++ octave-mod/scripts/plot/legend.m    2008-12-29 20:38:55.068279061 -0600
@@ -165,13 +165,13 @@
        nargs = numel (varargin);
       endif
     elseif (iscellstr (arg))
-      varargin = fliplr (arg);
+      varargin = arg;
       nargs = numel (varargin);
     else
       error ("legend: expecting argument to be a character string");
     endif
   else
-    varargin(1:nargs) = fliplr (varargin(1:nargs));
+    varargin(1:nargs) = varargin(1:nargs);
   endif
 
   if (nargs > 0)
@@ -191,7 +191,7 @@
   endif
 
   warned = false;
-  for i = 1:nargs
+  for i = nargs:-1:1
     arg = varargin{i};
     if (ischar (arg))
       while (k <= nkids

reply via email to

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