By default, 2-D graphs display in a rectangular axes that has
the same aspect ratio as the figure window. This makes optimum use
of space available for plotting. Set the aspect ratio with the axis
function:
axis normal
— Sets the axis
limits to span the data range along each axis and stretches the plot
to fit the figure window. This the default behavior.
axis square
— makes the
current axes region square
axis equal
— sets the aspect
ratio so that the data units are the same in every direction
axis equal tight
— sets
the aspect ratio so that the data units are the same in every direction
and then sets the axis limits to the minimum and maximum values of
the data.
For example, these statements create a elongated circle.
t = 0:pi/20:2*pi; x = sin(t); y = 2*cos(t); plot(x,y) grid on
These graphs show the effects of various axis command options:
These statements create a cylindrical surface:
t = 0:pi/6:4*pi; [x,y,z] = cylinder(4+cos(t),30); surf(x,y,z)
These graphs show the effects of various axis command options:
axis normal
— Sets the axis
limits to span the data range along each axis and stretches the plot
to fit the figure window. This the default behavior.
axis square
— Creates an
axes that is square regardless of the shape of the figure window.
The cylindrical surface is no longer distorted because it is not warped
to fit the window. However, the size of one data unit is not equal
along all axes (the z-axis spans only one unit while the x-axes and
y-axes span 10 units each).
axis
equal
—
Makes the length of one data unit equal along each axis while maintaining
a nearly square plot box. It also prevents warping of the axis to
fill the window's shape.
axis vis3d
— Freezes aspect
ratio properties to enable rotation of 3-D objects and overrides stretching
the axes to fill the figure. Use this option to keep settings from
changing while you rotate the scene.
Note:
To format aspect ratio using the |
You can also control the aspect ratio of your graph more precisely using these functions:
Specifying the relative scales of the x-, y-, and z-axes (data aspect ratio)
Specifying the shape of the space defined by the axes (plot box aspect ratio)
Specifying the axis limits
The following commands enable you to set these values.