Mercurial > hg > octave-nkf
changeset 17023:13a12d01aca5
Avoid tight limits having a span of zero.
script/plot/axis.m: For the "tight" option, avoid a span of zero.
(Bug # 39429)
author | bpabbott |
---|---|
date | Sat, 20 Jul 2013 10:56:24 -0400 |
parents | ddc62f0c7a35 |
children | c358c6e7416b |
files | scripts/plot/axis.m |
diffstat | 1 files changed, 20 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -344,16 +344,31 @@ function __do_tight_option__ (ca) - set (ca, - "xlim", __get_tight_lims__ (ca, "x"), - "ylim", __get_tight_lims__ (ca, "y")); + xlim = __get_tight_lims__ (ca, "x"); + if (all (xlim == 0)) + xlim = eps () * [-1 1]; + elseif (diff (xlim == 0)) + xlim = xlim .* (1 + eps () * [-1, 1]); + endif + ylim = __get_tight_lims__ (ca, "y"); + if (all (ylim == 0)) + ylim = eps () * [-1 1]; + elseif (diff (ylim == 0)) + ylim = ylim .* (1 + eps () * [-1, 1]); + endif + set (ca, "xlim", xlim, "ylim", ylim) if (__calc_dimensions__ (ca) > 2) - set (ca, "zlim", __get_tight_lims__ (ca, "z")); + zlim = __get_tight_lims__ (ca, "z"); + if (all (zlim == 0)) + zlim = eps () * [-1 1]; + elseif (diff (zlim == 0)) + zlim = zlim .* (1 + eps () * [-1, 1]); + endif + set (ca, "zlim", zlim); endif endfunction - %!demo %! clf; %! t = 0:0.01:2*pi;