Mercurial > hg > octave-terminal
changeset 7115:926fc75fb02e
[project @ 2007-11-07 15:42:46 by jwe]
author | jwe |
---|---|
date | Wed, 07 Nov 2007 15:42:46 +0000 |
parents | a67d30883ee0 |
children | c7992b210874 |
files | scripts/ChangeLog scripts/plot/__go_draw_axes__.m |
diffstat | 2 files changed, 59 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,11 @@ +2007-11-07 John W. Eaton <jwe@octave.org> + + * plot/__go_draw_axes__.m: Also set have_data to false if any of + the data limits are infinite. + (get_data_limits): Don't do anything if xdat or tx are empty. + (get_axis_limits): Don't do anything if min_val or max_val are + infinite. + 2007-11-06 David Bateman <dbateman@free.fr> * plot/hist.m: Pass any additional arguments to bar for
--- a/scripts/plot/__go_draw_axes__.m +++ b/scripts/plot/__go_draw_axes__.m @@ -782,7 +782,10 @@ endfor - have_data = ! isempty (data); + have_data = (! (isempty (data) + || isinf (xmin) || isinf (xmax) + || isinf (ymin) || isinf (ymax) + || isinf (zmin) || isinf (zmax))); if (xautoscale && have_data) xlim = get_axis_limits (xmin, xmax, xminp, xlogscale); @@ -798,7 +801,8 @@ else xdir = "noreverse"; endif - fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", xaxisloc, xlim, xdir); + fprintf (plot_stream, "set %srange [%.15e:%.15e] %s;\n", + xaxisloc, xlim, xdir); if (yautoscale && have_data) ylim = get_axis_limits (ymin, ymax, yminp, ylogscale); @@ -963,18 +967,20 @@ 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); - if (! isempty (tx)) - xminp = min (xminp, min (tx)); - endif - else - tmp = min (xdat(xdat > 0)); - if (! isempty (tmp)) - xminp = min (xminp, tmp); + if (! (isempty (xdat) || isempty (tx))) + xdat = xdat(! isinf (xdat)); + xmin = min (xmin, min (xdat)); + xmax = max (xmax, max (xdat)); + if (nargin == 5) + tx = tx(! isinf (xdat) & tx > 0); + if (! isempty (tx)) + xminp = min (xminp, min (tx)); + endif + else + tmp = min (xdat(xdat > 0)); + if (! isempty (tmp)) + xminp = min (xminp, tmp); + endif endif endif endfunction @@ -985,36 +991,38 @@ function lim = get_axis_limits (min_val, max_val, min_pos, logscale) - if (logscale) - if (isinf (min_pos)) - lim = []; - warning ("axis: logscale with no positive values to plot"); - return; - endif - if (min_val <= 0) - warning ("axis: omitting nonpositive data in log plot"); - min_val = min_pos; - endif - ## FIXME -- maybe this test should also be relative? - if (abs (min_val - max_val) < sqrt (eps)) - min_val *= 0.9; - max_val *= 1.1; + if (! (isinf (min_val) || isinf (max_val))) + if (logscale) + if (isinf (min_pos)) + lim = []; + warning ("axis: logscale with no positive values to plot"); + return; + endif + if (min_val <= 0) + warning ("axis: omitting nonpositive data in log plot"); + min_val = min_pos; + endif + ## FIXME -- maybe this test should also be relative? + if (abs (min_val - max_val) < sqrt (eps)) + min_val *= 0.9; + max_val *= 1.1; + endif + min_val = 10 ^ floor (log10 (min_val)); + max_val = 10 ^ ceil (log10 (max_val)); + else + if (min_val == 0 && max_val == 0) + min_val = -1; + max_val = 1; + ## FIXME -- maybe this test should also be relative? + elseif (abs (min_val - max_val) < sqrt (eps)) + min_val -= 0.1 * abs (min_val); + max_val += 0.1 * abs (max_val); + endif + ## FIXME -- to do a better job, we should consider the tic spacing. + scale = 10 ^ floor (log10 (max_val - min_val) - 1); + min_val = scale * floor (min_val / scale); + max_val = scale * ceil (max_val / scale); endif - min_val = 10 ^ floor (log10 (min_val)); - max_val = 10 ^ ceil (log10 (max_val)); - else - if (min_val == 0 && max_val == 0) - min_val = -1; - max_val = 1; - ## FIXME -- maybe this test should also be relative? - elseif (abs (min_val - max_val) < sqrt (eps)) - min_val -= 0.1 * abs (min_val); - max_val += 0.1 * abs (max_val); - endif - ## FIXME -- to do a better job, we should consider the tic spacing. - scale = 10 ^ floor (log10 (max_val - min_val) - 1); - min_val = scale * floor (min_val / scale); - max_val = scale * ceil (max_val / scale); endif lim = [min_val, max_val];