Main Content

Set or query *x*-axis limits

`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.