Getting Started | ![]() ![]() |
Controlling the Axes
The axis
command supports a number of options for setting the scaling, orientation, and aspect ratio of plots. You can also set these options interactively. See Editing Plots for more information.
Setting Axis Limits
By default, MATLAB finds the maxima and minima of the data to choose the axis limits to span this range. The axis
command enables you to specify your own limits
axis([xmin xmax ymin ymax])
or for three-dimensional graphs,
axis([xmin xmax ymin ymax zmin zmax])
axis auto
to re-enable MATLAB's automatic limit selection.
Setting Axis Aspect Ratio
axis
also enables you to specify a number of predefined modes. For example,
axis square
makes the x-axes and y-axes the same length.
axis equal
makes the individual tick mark increments on the x- and y-axes the same length. This means
plot(exp(i*[0:pi/10:2*pi]))
followed by either axis square
or axis equal
turns the oval into a proper circle.
axis auto normal
returns the axis scaling to its default, automatic mode.
Setting Axis Visibility
You can use the axis
command to make the axis visible or invisible.
axis on
makes the axis visible. This is the default.
axis off
Setting Grid Lines
The grid
command toggles grid lines on and off. The statement
grid on
grid off
![]() | Multiple Plots in One Figure | Axis Labels and Titles | ![]() |