Navigation

Operators and Keywords

Function List:

C++ API

: linkaxes (hax)
: linkaxes (hax, optstr)

Link the axis limits of 2-D plots such that a change in one is propagated to the others.

The axes handles to be linked are passed as the first argument hax.

The optional second argument is a string which defines which axis limits will be linked. The possible values for optstr are:

"x"

Link x-axes

"y"

Link y-axes

"xy" (default)

Link both axes

"off"

Turn off linking

If unspecified the default is to link both X and Y axes.

When linking, the limits from the first axes in hax are applied to the other axes in the list. Subsequent changes to any one of the axes will be propagated to the others.

See also: linkprop, addproperty.

Demonstration 1

The following code

 clf;
 hax1 = subplot (3,1,1);
 bar (rand (4, 1), "facecolor", "r");
 hax2 = subplot (3,1,2);
 bar (5*rand (4, 1), "facecolor", "g");
 hax3 = subplot (3,1,3);
 bar (10*rand (4, 1), "facecolor", "b");
 input ("Press  to link axes: ");
 linkaxes ([hax1, hax2, hax3]);
 input ("Press  to change ylim: ");
 ylim (hax3, [0 10]);

Produces the following output

Press  to link axes: 
Press  to change ylim:

and the following figure

Figure 1

Package: octave