zlim

Gets or sets the limits of the z-axis.

Category: Graphics > Formatting and Annotation

Syntax

zlim([zmin zmax])

Sets the z limits of the current axes.

lim = zlim

Returns the current limits as a two-element vector.

zlim('auto')

Returns to automatic limits that fit the data.

m = zlim('mode')

Returns 'auto' or 'manual'.

Description

Setting the limits switches the mode to manual, so later plots no longer rescale the z-axis. zlim('auto') undoes this. Data outside the limits is clipped.

Input arguments

[zmin zmax]
Two increasing numbers.

Output arguments

lim
Two-element row vector [zmin zmax].

Example

Fix and read z limits

surf(peaks(10))
zlim([-5 5])
disp(zlim)
zlim('auto')
disp(zlim('mode'))
Output
    -5     5
auto

See also

xlim ylim axis zlabel surf