This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Why Do Axis Limits Keep Changing When Using axis Commands?

In R2014a and earlier, if you set the axis limits using an axis tight or an axis image command, then the calculated axis limits do not change. If you add new data to the axes outside of the current axis limits, then the limits do not automatically update to encompass the data.

Starting in R2014b, if you use these commands and afterwards add new data to the axes, then the axis limits automatically update to encompass the new data.

For example, this code sets the axis limits using the axis tight command, and then adds new data to the graph. Starting in R2014b, the limits update to encompass both lines.

line([10 20],[3 4],'Color','red')
axis tight
line([0 10],[1 2],'Color','blue')

If you run the same code in previous releases, the limits do not update so the blue line is not visible in the axes.

In R2014a and earlier, these axis commands set the axis limit modes (XLimMode, YLimMode, and ZLimMode) to 'manual'. When the limit modes are manual, the limits do not update to reflect changes in the data. Starting in R2014b, these axis commands set the axis limit modes to 'auto'. When the limit modes are auto, the limits automatically update to reflect changes in the data.

Starting in R2014b, to keep the axis limits from automatically updating, append manual to the end of the axis command. For example, axis tight manual. The manual option sets the limit modes to manual, as in previous releases, so that the limits do not automatically update. For example, this code does not update the limits to encompass the second blue line.

line([10 20],[3 4], 'Color', 'red');
axis tight manual;
line([0 10],[1 2], 'Color', 'blue');

See Also

Functions

Properties