Main Content

Set or query *z*-axis limits

`zlim(`

sets
the `limits`

)*z*-axis limits for the current axes. Specify `limits`

as
a two-element vector of the form `[zmin zmax]`

, where `zmax`

is
greater than `zmin`

.

`zlim(`

specifies the
limit method MATLAB`limitmethod`

)^{®} uses for automatic limit selection. Specify the limit method as
`'tickaligned'`

, `'tight'`

, or
`'padded'`

. MATLAB sets the `ZLimitMethod`

property of the axes to
the value you specify.

You can specify the `limitmethod`

argument without
parentheses. For example, `zlim tight`

enables tight
*z*-axis limits.

`zlim(`

specifies automatic
or manual limit selection. The `limitmode`

)`limitmode`

can have either of
two values:

`'auto'`

— Enable automatic limit selection. MATLAB selects the limits based on the range of your data and the value of the`ZLimitMethod`

property of the axes. If you plot into the axes multiple times, the limits update to encompass all the data.`'manual'`

— Freeze the*z*-axis limits at their current value.

You can specify the `limitmode`

argument without
parentheses. For example, `zlim auto`

enables automatic limit
selection.

returns
the current `m`

= zlim('mode')*z*-axis limits mode, which is either `'auto'`

or `'manual'`

.
By default, the mode is automatic unless you specify limits or set
the mode to manual.

`___ = zlim(`

uses the axes specified by `ax`

,___)`ax`

instead of the current axes.
Specify `ax`

as the first input argument for any of the
previous syntaxes. You can include an output argument if the original syntax
supports an output argument. Use single quotes around the mode inputs, for
example, `zlim(ax,'auto')`

.

The `zlim`

function sets and queries several
axes properties related to the *z*-axis limits.

`ZLim`

— Property that stores the*z*-axis limits.`ZLimMode`

— Property that stores the*z*-axis limits mode. When you set the*z*-axis limits, this property changes to`'manual'`

.`ZLimitMethod`

— Property that controls how the*z*-axis limits are calculated when the`ZLimMode`

property is set to`'auto'`

.