Next: , Up: Two-Dimensional Plots


15.2.1.1 Axis Configuration

The axis function may be used to change the axis limits of an existing plot and various other axis properties, such as the aspect ratio and the appearance of tic marks.

— Function File: axis ()
— Function File: axis ([x_lo x_hi])
— Function File: axis ([x_lo x_hi y_lo y_hi])
— Function File: axis ([x_lo x_hi y_lo y_hi z_lo z_hi])
— Function File: axis (option)
— Function File: axis (..., option)
— Function File: axis (h, ...)
— Function File: limits = axis ()

Set axis limits for plots.

The argument limits should be a 2-, 4-, or 6-element vector. The first and second elements specify the lower and upper limits for the x-axis. The third and fourth specify the limits for the y-axis, and the fifth and sixth specify the limits for the z-axis.

Without any arguments, axis turns autoscaling on.

With one output argument, x = axis returns the current axes.

The vector argument specifying limits is optional, and additional string arguments may be used to specify various axis properties. For example,

          axis ([1, 2, 3, 4], "square");

forces a square aspect ratio, and

          axis ("tic", "labely");

turns tic marks on for all axes and tic mark labels on for the y-axis only.

The following options control the aspect ratio of the axes.

"square"
Force a square aspect ratio.
"equal"
Force x distance to equal y-distance.
"normal"
Restore the balance.

The following options control the way axis limits are interpreted.

"auto"
Set the specified axes to have nice limits around the data or all if no axes are specified.
"manual"
Fix the current axes limits.
"tight"
Fix axes to the limits of the data.

The option "image" is equivalent to "tight" and "equal".

The following options affect the appearance of tic marks.

"on"
Turn tic marks and labels on for all axes.
"off"
Turn tic marks off for all axes.
"tic[xyz]"
Turn tic marks on for all axes, or turn them on for the specified axes and off for the remainder.
"label[xyz]"
Turn tic labels on for all axes, or turn them on for the specified axes and off for the remainder.
"nolabel"
Turn tic labels off for all axes.
Note, if there are no tic marks for an axis, there can be no labels.

The following options affect the direction of increasing values on the axes.

"ij"
Reverse y-axis, so lower values are nearer the top.
"xy"
Restore y-axis, so higher values are nearer the top.

If an axes handle is passed as the first argument, then operate on this axes rather than the current axes.

Similarly the axis limits of the colormap can be changed with the caxis function.

— Function File: caxis (limits)
— Function File: caxis (h, ...)

Set color axis limits for plots.

The argument limits should be a 2-element vector specifying the lower and upper limits to assign to the first and last value in the colormap. Values outside this range are clamped to the first and last colormap entries.

If limits is 'auto', then automatic colormap scaling is applied, whereas if limits is 'manual' the colormap scaling is set to manual.

Called without any arguments to current color axis limits are returned.

If an axes handle is passed as the first argument, then operate on this axes rather than the current axes.

The xlim, ylim, and zlim functions may be used to get or set individual axis limits. Each has the same form.

— Function File: xl = xlim ()
— Function File: xlim (xl)
— Function File: m = xlim ('mode')
— Function File: xlim (m)
— Function File: xlim (h, ...)

Get or set the limits of the x-axis of the current plot. Called without arguments xlim returns the x-axis limits of the current plot. If passed a two element vector xl, the limits of the x-axis are set to this value.

The current mode for calculation of the x-axis can be returned with a call xlim ('mode'), and can be either 'auto' or 'manual'. The current plotting mode can be set by passing either 'auto' or 'manual' as the argument.

If passed a handle as the first argument, then operate on this handle rather than the current axes handle.

See also: ylim, zlim, set, get, gca.