Mercurial > octave
changeset 32100:10daf5ce7f28
Set "tight" axes limits by default for pcolor() plot (bug #64244)
* NEWS.9.md: Announce change in Matlab Compatibility section.
* pcolor.m: Set axes properties "[xyz]limitmethod" to "tight" so that
plot just encompasses the given data.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 30 May 2023 17:04:52 -0700 |
parents | d039fbf92297 |
children | aaaee134c8df |
files | etc/NEWS.9.md scripts/plot/draw/pcolor.m |
diffstat | 2 files changed, 6 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/etc/NEWS.9.md Mon May 22 16:22:42 2023 -0700 +++ b/etc/NEWS.9.md Tue May 30 17:04:52 2023 -0700 @@ -93,6 +93,9 @@ of the generalized eigenvalues has been removed (one can use the `ordqz` function for that purpose). +- `pcolor` now sets the axes limits to be just large enough to display the +plotted data (equivalent of `axis tight`). + ### Alphabetical list of new functions added in Octave 9 * `isuniform`
--- a/scripts/plot/draw/pcolor.m Mon May 22 16:22:42 2023 -0700 +++ b/scripts/plot/draw/pcolor.m Tue May 30 17:04:52 2023 -0700 @@ -91,44 +91,9 @@ set (htmp, "facecolor", "flat"); if (! ishold ()) set (hax, "view", [0, 90], "box", "on"); - ## FIXME: Maybe this should be in the general axis limit setting routine? - ## When values are integers (such as from meshgrid), we want to - ## use tight limits for pcolor, mesh, surf, etc. Situation is - ## complicated immensely by vector or matrix input and meshgrid() - ## or ndgrid() format. - meshgrid_fmt = true; - if (isvector (x)) - xrng = x(isfinite (x)); - else - xrng = x(1, isfinite (x(1,:))); # meshgrid format (default) - if (all (xrng == xrng(1))) - xrng = x(isfinite (x(:,1)), 1); # ndgrid format - meshgrid_fmt = false; - endif - endif - if (isvector (y)) - yrng = y(isfinite (y)); - else - if (meshgrid_fmt) - yrng = y(isfinite (y(:,1)), 1); - else - yrng = y(1, isfinite (y(1,:))); - endif - endif - if (all (xrng == fix (xrng))) - xmin = min (xrng); - xmax = max (xrng); - if (xmin < xmax) - xlim ([xmin, xmax]); - endif - endif - if (all (yrng == fix (yrng))) - ymin = min (yrng); - ymax = max (yrng); - if (ymin < ymax) - ylim ([ymin, ymax]); - endif - endif + set (hax, "xlimmode", "auto", "ylimmode", "auto", "zlimmode", "auto", + "xlimitmethod", "tight", "ylimitmethod", "tight", + "zlimitmethod", "tight"); endif unwind_protect_cleanup