Axis limits, specified as a vector of four, six, or eight elements
in one of these forms:
[xmin xmax ymin ymax]
—
Set the x-axis limits to range from xmin
to xmax
.
Set the y-axis limits to range from ymin
to ymax
.
[xmin xmax ymin ymax zmin zmax]
—
Additionally set the z-axis limits to range from zmin
to zmax
.
[xmin xmax ymin ymax zmin zmax cmin cmax]
—
Additionally set the color limits. cmin
is the
data value that maps to the first color in the colormap. cmax
is
the data value that maps to the last color in the colormap.
Note:
For partially automatic limits, use inf or -inf for
the limits you want the axes to choose automatically. For example, axis([-inf
10 0 inf]) lets the axes choose the appropriate minimum x-axis
limit and maximum y-axis limit. It uses the specified
values for the maximum x-axis limit and minimum y-axis
limit. |
If you specify the limits, then the XLim
, YLim
, ZLim
,
and CLim
properties
for the axes change to the specified values. Additionally, the associated
mode properties change to 'manual'
.
Example: [0 1 0 1]
Example: [0
1 0 1 0 1]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Manual, automatic, or semiautomatic selection of axis limits,
specified as one of the values in this table.
Value | Description | Axes Properties That Change |
manual | Freeze all axis limits at their current values. | Sets XLimMode , YLimMode ,
and ZLimMode to 'manual' . |
auto | The axes automatically chooses all axis limits. | Sets XLimMode , YLimMode ,
and ZLimMode to 'auto' . |
'auto x' | The axes automatically chooses the x-axis
limits. | Sets XLimMode to 'auto' . |
'auto y' | The axes automatically chooses the y-axis
limits. | Sets YLimMode to 'auto' . |
'auto z' | The axes automatically chooses the z-axis
limits. | Sets ZLimMode to 'auto' . |
'auto xy' | The axes automatically chooses the x-axis
and y-axis limits. | Sets XLimMode and YLimMode to 'auto' . |
'auto xz' | The axes automatically chooses the x-axis
and z-axis limits. | Sets XLimMode and ZLimMode to 'auto' . |
'auto yz' | The axes automatically chooses the y-axis
and z-axis limits. | Sets YLimMode and ZLimMode to 'auto' . |
Axis limits and scaling, specified as one of these values.
Value | Description | Axes Properties That Change |
tight | Fit the axes box tightly around the data by setting the axis
limits equal to the range of the data. | XLimMode , YLimMode , and ZLimMode change
to 'auto' . The limits automatically update to incorporate
new data added to the axes. To keep the limits from changing when
using hold on , use axis
tight manual . |
equal | Use the same length for the data units along each axis. | Sets DataAspectRatio to [1 1 1] ,
sets PlotBoxAspectRatio to [3 4 4] ,
and sets the associated mode properties to manual. Disables the "stretch-to-fill"
behavior. |
image | Use the same length for the data units along each axis and
fit the axes box tightly around the data. | Sets DataAspectRatio to [1 1 1] and
sets the associated mode property to manual. Disables the "stretch-to-fill"
behavior. |
square | Use axis lines with equal lengths. Adjust the increments between
data units accordingly. | Sets PlotBoxAspectRatio to [1 1
1] and sets the associated mode property to manual. Disables
the "stretch-to-fill" behavior. |
fill | Enable the "stretch-to-fill" behavior (the default).
The lengths of each axis line fill the position rectangle defined
in the Position property
of the axes. | Sets the plot box aspect ratio mode and data aspect ratio mode
properties to auto. |
vis3d | Freeze the aspect ratio properties. | Sets the plot box aspect ratio mode and data aspect ratio mode
properties to manual. |
normal | Restore the default behavior. | Sets the plot box aspect ratio mode and data aspect ratio mode
properties to auto. |
For more information on the plot box aspect ratio and the data
aspect ratio, see the PlotBoxAspectRatio
and DataAspectRatio
properties
for the axes.
You can combine style options. The options are evaluated from
left to right, so subsequent options can overwrite properties set
by prior ones.
y-axis direction, specified as one of these
values:
xy
— Default direction.
For axes with a 2-D view, the y-axis is vertical
with values increasing from bottom to top.
ij
— Reverse direction.
For axes with a 2-D view, the y-axis is vertical
with values increasing from top to bottom.
Axes lines and background visibility, specified as either on
or off
.
Specifying the visibility sets the Visible
property of the
axes to the same value.
Axes objects, specified as a scalar or a vector. If you do not
specify an axes, then axis
sets the limits for
the current axes (gca
).
When you specify an axes, use single quotes around other input
arguments that are character strings.
Example: axis(ax,'tight')
Example: axis(ax,limits)
Example: axis(ax,'manual')