# HG changeset patch # User Ben Abbott # Date 1289177146 -28800 # Node ID 6c8791cb35b19482d51702153121165c76159e07 # Parent abc0c6b0a4c418c0100a0a9b11d037425e90daad __go_draw_axes__.m: Set proper tight axis limits for log scale. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2010-11-08 Ben Abbott + + * plot/__go_draw_axes__.m, plot/axis.m: Set proper tight axis limits + for log scale. + 2010-11-07 David Bateman * plot/legend.m: Remove call to drawnow. diff --git a/scripts/plot/__go_draw_axes__.m b/scripts/plot/__go_draw_axes__.m --- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -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); diff --git a/scripts/plot/axis.m b/scripts/plot/axis.m --- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -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]") +