Navigation

Operators and Keywords

Function List:

C++ API

: xlimits = xlim ()
: xmode = xlim ("mode")
: xlim ([x_lo x_hi])
: xlim ("auto")
: xlim ("manual")
: xlim (hax, …)

Query or set the limits of the x-axis for the current plot.

Called without arguments xlim returns the x-axis limits of the current plot.

With the input query "mode", return the current x-limit calculation mode which is either "auto" or "manual".

If passed a 2-element vector [x_lo x_hi], the limits of the x-axis are set to these values and the mode is set to "manual". The special values -Inf and Inf can be used to indicate that either the lower axis limit or upper axis limit should be automatically calculated.

The current plotting mode can be changed by using either "auto" or "manual" as the argument.

If the first argument hax is an axes handle, then operate on this axis rather than the current axes returned by gca.

Programming Note: The xlim function operates by modifying the "xlim" and "xlimmode" properties of an axes object. These properties can be be directly inspected and altered with get/set.

See also: ylim, zlim, axis, set, get, gca.

Demonstration 1

The following code

 clf;
 line ();
 xlim ([0.2, 0.8]);
 title ("xlim is [0.2, 0.8]");

Produces the following figure

Figure 1

Demonstration 2

The following code

 clf;
 line ();
 xlim auto;
 title ("xlim is auto");

Produces the following figure

Figure 1

Demonstration 3

The following code

 clf;
 plot3 ([0,1], [0,1], [0,1]);
 xlim ([0.2, 0.8]);
 title ("xlim is [0.2, 0.8]");

Produces the following figure

Figure 1

Demonstration 4

The following code

 clf;
 plot3 ([0,1], [0,1], [0,1]);
 xlim ("auto");
 title ("xlim is auto");

Produces the following figure

Figure 1

Package: octave