Link graphic object properties, such that a change in one is propagated to the others.
The input h is a vector of graphic handles to link.
prop may be a string when linking a single property, or a cell array of strings for multiple properties. During the linking process all properties in prop will initially be set to the values that exist on the first object in the list h.
The function returns hlink which is a special object describing the
link. As long as the reference hlink exists the link between graphic
objects will be active. This means that hlink must be preserved in
a workspace variable, a global variable, or otherwise stored using a
function such as setappdata
, guidata
. To unlink properties,
execute clear hlink
.
An example of the use of linkprop
is
x = 0:0.1:10; subplot (1,2,1); h1 = plot (x, sin (x)); subplot (1,2,2); h2 = plot (x, cos (x)); hlink = linkprop ([h1, h2], {"color","linestyle"}); set (h1, "color", "green"); set (h2, "linestyle", "--");
See also: linkaxes.
The following code
clf; x = 0:0.1:10; subplot (1,2,1); h1 = plot (x, sin (x), "r"); subplot (1,2,2); h2 = plot (x, cos (x), "b"); input ("Pressto link plots: "); hlink = linkprop ([h1, h2], {"color", "linestyle"}); input ("Press to change color: "); set (h1, "color", "green"); input ("Press to change linestyle: "); set (h2, "linestyle", "--");
Produces the following output
Pressto link plots: Press to change color: Press to change linestyle:
and the following figure
Figure 1 |
---|
Package: octave