Set or query z-axis limits
This example illustrates how to set the x-, y-, and z-axis limits to match the actual range of the data, rather than the rounded values of[-2 3] for the x-axis ,[-2 4] for the y-axis and [-0.5 0.5] for z-axis originally selected by MATLAB®.
[x,y] = meshgrid([-1.75:.2:3.25]); z = x.*exp(-x.^2-y.^2); surf(x,y,z) xlim([-1.75 3.25]) ylim([-1.75 3.25]) zlim([-0.45 0.45])
To control the upper and lower axis limits on a graph, use the Property Editor, one of the plotting tools . For details, see The Property Editor.
When the axis limit mode is set to auto (the default), MATLAB uses limits, which are round numbers, to span the range of the data being displayed. Setting a value for any of the limits also sets the corresponding mode to manual. If you set the limits on an existing graph and want to maintain these limits while adding more graphs, use the hold command.