When plotting functions create graphs, many of the axes properties that are under automatic control adjust to best display the graph. These properties adjust automatically when their associated mode property is set to auto (which is the default). The following table lists the axes automatic-mode properties.
Note: When setting any mode property to 'manual' from within a function, you should call drawnow first to ensure the corresponding property has been updated to the latest value.
What It Controls
Positioning of the viewpoint
Positioning of the camera target in the axes
The direction of "up" in 2-D and 3-D views
The size of the projected scene and stretch-to-fit behavior
Mapping of data values to colors
Relative scaling of data units along x-, y-, and z-axes and stretch-to-fit behavior
Relative scaling of plot box along x-, y-, and z-axes and stretch-to-fit behavior
Direction of axis tick marks (in for 2-D, out for 3-D)
Limits of the respective x, y, and z axes
Tick mark spacing along the respective x-, y-, and z-axes
Tick mark labels along the respective x-, y-, and z-axes
For example, these statements graph two lines:
x = 1:10; y = 1:10; plot(x,y) hold on plot(x,y.^2)
The second plot statement causes the axes YLim property to change from [0,10] to [0,100].
This is because YLimMode is auto, which means the axes recompute the axis limits whenever necessary.
If you assign a value to a property controlled by an automatic-mode property, MATLAB® sets the mode property to manual. When the mode property is manual, the axes does not automatically recompute the property value.
x = 1:10; y = 1:10; plot(x,y) hold on ax = gca; ax.XLim = [1,10]; ax.YLim = [1,20]; plot(x,y.^2)
Setting values for the XLim and YLim properties changes the XLimMode and YLimMode properties to manual. The second plot statement draws a line that is clipped to the axis limits instead of causing the axes to recompute its limits.