set1limtight
After setting xlim (or zooming), it is sometimes useful to set ylim to the full range of the ydata WITHIN xlim.
ylim([-inf inf]) will set ylim at min(ydata) to max(ydata)."axis tight" does the same, and also sets xlim([min(xdata) max(xdata)]). In both cases ylim is calculated from the full ydata, and not just the ydata that is visible at the current xlim.
set1limtight('y') sets ylim to min and max of the ydata within range xlim. It leaves xlim unchanged.
set1limtight('x') same for xlim
set1limtight('y',ah) sets ylim for axes handle ah
Example:
x = 0:0.1:7; y = [sin(x); sin(x+0.2)*0.95];
plot(x,y,'o-');
xlim([1.15 2.45]);
set1limtight('y')
Cite As
Bart van Oort (2024). set1limtight (https://www.mathworks.com/matlabcentral/fileexchange/40373-set1limtight), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.2.0.0 | fixed typo in description |
||
1.1.0.0 | 1) added option to select 'x' or 'y', and to pass an axes handle (passing multiple axes handles is not implemented)
|
||
1.0.0.0 |