Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Set or query *x*-axis limits

`xlim(limits)`

`xl = xlim`

`xlim auto`

`xlim manual`

`m = xlim('mode')`

`___ = xlim(target,___)`

`xlim(`

sets the `limits`

)*x*-axis
limits for the current axes or chart. Specify `limits`

as a
two-element vector of the form `[xmin xmax]`

, where
`xmax`

is greater than `xmin`

.

`xlim auto`

sets an automatic mode, enabling
the axes to determine the *x*-axis limits. The
limits span the range of the plotted data. Use this option if you
change the limits and then want to set them back to the default values.
This command sets the `XLimMode`

property for the
axes to `'auto'`

.

`xlim manual`

sets a manual mode, freezing
the limits at the current values. Use this option if you want to retain
the current limits when adding new data to the axes using the ```
hold
on
```

command. This command sets the `XLimMode`

property
for the axes to `'manual'`

.

returns
the current `m`

= xlim('mode')*x*-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.

`___ = xlim(`

uses
the axes or chart 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, `xlim(target,'auto')`

.

The `xlim`

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

Was this topic helpful?