copyobj

Copies graphics objects into a new parent.

Category: Graphics > Graphics Objects

Syntax

new = copyobj(h, parent)

Copies the objects in h and attaches the copies to parent.

Description

The copy keeps the property values of the original. The parent must be able to hold that kind of object: a line goes into axes, an axes goes into a figure. Copying a line into another axes is the quick way to reuse a curve in a second plot.

Input arguments

h
Handle or array of handles to copy, including their children.
parent
Destination: a figure, axes or other valid container, or an array matching h.

Output arguments

new
Handles of the copies.

Example

Duplicate a line

figure
ax = axes;
h = plot(1:3);
g = copyobj(h, ax);
disp(numel(allchild(ax)))
Output
     2

See also

allchild delete findobj plot