diff scripts/plot/axis.m @ 11201:6c8791cb35b1

__go_draw_axes__.m: Set proper tight axis limits for log scale.
author Ben Abbott <bpabbott@mac.com>
date Mon, 08 Nov 2010 08:45:46 +0800
parents 01ddaedd6ad5
children fd0a3ac60b0e
line wrap: on
line diff
--- a/scripts/plot/axis.m	Sun Nov 07 22:57:23 2010 +0100
+++ b/scripts/plot/axis.m	Mon Nov 08 08:45:46 2010 +0800
@@ -319,6 +319,10 @@
     lims = get (ca, strcat (ax, "lim"));
   else
     data = get (kids, strcat (ax, "data"));
+    scale = get (ca, strcat (ax, "scale"));
+    if (strcmp (scale, "log"))
+      data(data<=0) = NaN;
+    end
     if (iscell (data))
       data = data (find (! cellfun (@isempty, data)));
       if (! isempty (data))
@@ -333,7 +337,6 @@
     endif
   endif
 
-
 endfunction
 
 function __do_tight_option__ (ca)
@@ -483,3 +486,11 @@
 %! pcolor(s*x+x1,s*y+x1/2,5*z)
 %! axis tight
 
+%!demo
+%! clf
+%! x = -10:10;
+%! plot (x, x, x, -x)
+%! set (gca, "yscale", "log")
+%! legend ({"x >= 1", "x <= 1"}, "location", "north")
+%! title ("ylim = [1, 10]")
+