changeset 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 abc0c6b0a4c4
children 1840a0ecf1fb
files scripts/ChangeLog scripts/plot/__go_draw_axes__.m scripts/plot/axis.m
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sun Nov 07 22:57:23 2010 +0100
+++ b/scripts/ChangeLog	Mon Nov 08 08:45:46 2010 +0800
@@ -1,3 +1,8 @@
+2010-11-08  Ben Abbott <bpabbott@mac.com>
+
+	* plot/__go_draw_axes__.m, plot/axis.m: Set proper tight axis limits
+	for log scale.
+
 2010-11-07  David Bateman  <dbateman@free.fr>
 
 	* plot/legend.m: Remove call to drawnow.
--- a/scripts/plot/__go_draw_axes__.m	Sun Nov 07 22:57:23 2010 +0100
+++ b/scripts/plot/__go_draw_axes__.m	Mon Nov 08 08:45:46 2010 +0800
@@ -405,6 +405,16 @@
         continue;
       endif
 
+      if (xlogscale)
+        obj.xdata(obj.xdata<=0) = NaN;
+      endif
+      if (ylogscale)
+        obj.ydata(obj.ydata<=0) = NaN;
+      endif
+      if (zlogscale)
+        obj.zdata(obj.zdata<=0) = NaN;
+      endif
+
       ## Check for facecolor interpolation for surfaces.
       doing_interp_color = ...
          isfield (obj, "facecolor") && strncmp (obj.facecolor, "interp", 6);
--- 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]")
+