Why do axes limits keep changing when using axis commands in MATLAB R2014b?

33 views (last 30 days)
I am plotting a series of lines on an axes. After I have plot one line using the 'line' function, I use the command:
axes tight
The above command sets the axes limits to a specific value, after which I add additional lines using additional 'line' commands. In MATLAB R2014a, adding additional plots did not change the axes limits. However in MATLAB R2014b, adding additional plots changes the axes limits each time I add a new plot. Why is this so?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 25 Aug 2014
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.
line([10 20],[3 4],'Color','red')
axis tight
line([0 10],[1 2],'Color','blue')
 
Starting in R2014b, the limits update to encompass both lines.
 
In R2014a and earlier, 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.
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');

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Products


Release

R2014b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!