axis

Sets axis limits and scaling, or gets the current limits.

Category: Graphics > Formatting and Annotation

Syntax

axis([xmin xmax ymin ymax])

Sets the x and y limits (add zmin zmax for 3-D).

lims = axis

Returns the current limits.

axis style

Applies a style such as tight, equal, square, image, padded, ij, xy, auto, manual.

axis on / axis off

Shows or hides the axis lines, ticks and labels.

Description

axis tight fits the limits to the data, axis equal gives all axes the same unit length so circles look round, and axis square makes the axes box square. axis ij puts the origin at the upper left, as for matrices and images.

The individual limits are also available through xlim, ylim and zlim.

Input arguments

limits
Vector of limits. Use -inf or inf to leave a bound automatic.
style
Option word, given in command form: axis equal.

Output arguments

lims
Row vector [xmin xmax ymin ymax], with the z limits added for 3-D axes.

Example

Setting and reading the limits

plot(1:10)
axis([0 5 0 20])
disp(axis)
Output
     0     5     0    20

See also

xlim ylim daspect grid