Say I have the following Matlab code:
figure;
a=plot(1:10); %A
pause();
set(a,'ydata',1:2:20); %B
pause();
set(a,'ydata',1:10); %C
At (A) the vertical range of my plot is [1,10].
At (B) the vertical range of my plot is [0,20].
At (C), the vertical range is once again [1,10].
I like that the plot auto-scales from step (A) to (B). I don’t like the auto-scaling from (B) to (C) – it makes things jump around too much.
Is there a way to have set the plot’s scale to expand but never shrink?
In my mind, this looks like:
set(gca,'XLimMode','auto_maxever');
To my knowledge, Matlab does not have a function such as you describe, however…
You can set exactly the limits of
XandYby doing the following command:A quick alias for the very same command is:
You might as well “freeze” the limits at any moment you like, by changing the
XLimModeandYLimModefromAutotoManual:Or you can use yet another alias, which does exactly the same:
If data is being continuously acquired, consider saving the axis limits before each update and then performing manual scaling.