Set or query y-axis limits
ylim(
sets the y-axis
limits for the current axes or chart. Specify limits
)limits
as a
two-element vector of the form [ymin ymax]
, where
ymax
is greater than ymin
.
ylim(
specifies the
limit method MATLAB® uses for automatic limit selection. Specify the limit method as
limitmethod
)'tickaligned'
, 'tight'
, or
'padded'
. MATLAB sets the YLimitMethod
property of the axes to
the value you specify. The limit method is not supported for standalone
visualizations.
You can specify the limitmethod
argument without
parentheses. For example, ylim tight
enables tight
y-axis limits.
ylim(
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 YLimitMethod
property of the
axes. If you plot into the axes multiple times, the limits update to
encompass all the data.
'manual'
— Freeze the y-axis
limits at their current value.
You can specify the limitmode
argument without
parentheses. For example, ylim auto
enables automatic limit
selection.
returns
the current y-axis limits mode, which is either m
= ylim('mode')'auto'
or 'manual'
.
By default, the mode is automatic unless you specify limits or set
the mode to manual.
___ = ylim(
uses the axes or standalone visualization specified by
target
,___)target
instead of the current axes. Specify
target
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, ylim(target,'auto')
.
The ylim
function sets and queries several
axes properties related to the y-axis limits.
YLim
—
Property that stores the y-axis limits.
YLimMode
— Property that stores the y-axis limits mode.
When you set the y-axis limits, this property changes
to 'manual'
.
YLimitMethod
— Property that controls how the y-axis limits
are calculated when the YLimMode
property is set to
'auto'
.