Mercurial > hg > octave-lyh
changeset 6453:4067a8caff18
[project @ 2007-03-26 14:15:24 by jwe]
author | jwe |
---|---|
date | Mon, 26 Mar 2007 14:15:24 +0000 |
parents | 7e90124eddba |
children | 7c9b4a6e090b |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m |
diffstat | 2 files changed, 36 insertions(+), 42 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,9 @@ +2007-03-26 John W. Eaton <jwe@octave.org> + + * plot/__go_draw_axes__.m (get_data_limits): New function. + Check for Inf too. + (__go_draw_axes__): Use get_data_limits. + 2007-03-24 John W. Eaton <jwe@octave.org> * plot/drawnow.m: If GNUTERM is set to wxt in the environment,
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -226,9 +226,9 @@ data_idx = 0; data = cell (); - xminp = yminp = zminp = Inf; - xmax = ymax = zmax = -Inf; - xmin = ymin = zmin = Inf; + xminp = yminp = zminp = realmax (); + xmax = ymax = zmax = -realmax (); + xmin = ymin = zmin = realmax (); palette_set = 0; @@ -371,19 +371,13 @@ ydat = obj.ydata(:); zdat = obj.zdata(:); if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (xdat(xdat>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); endif if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ydat(ydat>0))); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); endif if (zautoscale) - zmin = min (zmin, min (zdat)); - zmax = max (zmax, max (zdat)); - zminp = min (zminp, min (zdat(zdat>0))); + [zmin, zmax, zminp] = get_data_limits (zmin, zmax, zminp, zdat); endif data{data_idx} = [xdat, ydat, zdat]'; usingclause{data_idx} = "using ($1):($2):($3)"; @@ -420,18 +414,14 @@ yhi = ydat+udat; if (yautoscale) ty = [ydat; ylo; yhi]; - ymin = min (ymin, min (ty)); - ymax = max (ymax, max (ty)); - yminp = min (yminp, min (ty(ty>0))); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ty); endif if (xerr) xlo = xdat-xldat; xhi = xdat+xudat; if (xautoscale) tx = [xdat; xlo; xhi]; - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); endif data{data_idx} = [xdat, ydat, xlo, xhi, ylo, yhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4):($5):($6)"; @@ -439,9 +429,8 @@ data_idx); else if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (tx(tx>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, + xminp, xdat, tx); endif data{data_idx} = [xdat, ydat, ylo, yhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; @@ -453,14 +442,11 @@ xhi = xdat+xudat; if (xautoscale) tx = [xdat; xlo; xhi]; - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); endif if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ty(ty>0))); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, + yminp, ydat, ty); endif data{data_idx} = [xdat, ydat, xlo, xhi]'; usingclause{data_idx} = "using ($1):($2):($3):($4)"; @@ -468,14 +454,10 @@ data_idx); else if (xautoscale) - xmin = min (xmin, min (xdat)); - xmax = max (xmax, max (xdat)); - xminp = min (xminp, min (xdat(xdat>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat); endif if (yautoscale) - ymin = min (ymin, min (ydat)); - ymax = max (ymax, max (ydat)); - yminp = min (yminp, min (ydat(ydat>0))); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ydat); endif data{data_idx} = [xdat, ydat]'; usingclause{data_idx} = "using ($1):($2)"; @@ -506,21 +488,15 @@ zdat = obj.zdata; if (xautoscale) tx = xdat(:); - xmin = min (xmin, min (tx)); - xmax = max (xmax, max (tx)); - xminp = min (xminp, min (tx(tx>0))); + [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, tx); endif if (yautoscale) ty = ydat(:); - ymin = min (ymin, min (ty)); - ymax = max (ymax, max (ty)); - yminp = min (yminp, min (ty(ty>0))); + [ymin, ymax, yminp] = get_data_limits (ymin, ymax, yminp, ty); endif if (zautoscale) tz = zdat(:); - zmin = min (zmin, min (tz)); - zmax = max (zmax, max (tz)); - zminp = min (zminp, min (tz(tz>0))); + [zmin, zmax, zminp] = get_data_limits (zmin, zmax, zminp, tz); endif err = false; if (isvector (xdat) && isvector (ydat) && ismatrix (zdat)) @@ -735,6 +711,18 @@ endfunction +function [xmin, xmax, xminp] = get_data_limits (xmin, xmax, xminp, xdat, tx) + xdat = xdat(! isinf (xdat)); + xmin = min (xmin, min (xdat)); + xmax = max (xmax, max (xdat)); + if (nargin == 5) + tx = tx(! isinf (xdat) & tx > 0); + xminp = min (xminp, min (tx)); + else + xminp = min (xminp, min (xdat(xdat>0))); + endif +endfunction + ## Attempt to make "nice" limits from the actual max and min of the ## data. For log plots, we will also use the smallest strictly positive ## value.