Copy graphics objects and their descendants
Syntax
new_handle = copyobj(h,p)
Description
copyobj
creates copies of graphics objects. The copies are identical to the original objects except the copies have different values for their Parent
property and a new handle. The new parent must be appropriate for the copied object (e.g., you can copy a Line object only to another Axes object).
new_handle = copyobj(h,p)
copies one or more graphics objects identified by h
and returns the handle of the new object or a vector of handles to new objects. The new graphics objects are children of the graphics objects specified by p
.
Remarks
h
and p
can be scalars or vectors. When both are vectors, they must be the same length and the output argument, new_handle,
is a vector of the same length. In this case, new_handle(i)
is a copy of h(i)
with its Parent
property set to p(i)
.
When h
is a scalar and p
is a vector, h
is copied once to each of the parents in p
. Each new_handle(i)
is a copy of h
with its Parent
property set to p(i)
, and length(new_handle)
equals length(p)
.
When h
is a vector and p
is a scalar, each new_handle(i)
is a copy of h(i)
with its Parent
property set to p
. The length of new_handle
equals length(h)
.
Graphics objects are arranged as a hierarchy. Here, each graphics object is shown connected below its appropriate parent object.
Examples
Copy a Surface to a new Axes within a different Figure:
h = surf(peaks);
colormap hot
figure % Create a new Figure
axes % Create an Axes object in the Figure
new_handle = copyobj(h,gca);
colormap hot
view(3)
grid on
Note that while the Surface is copied, the colormap (Figure property), view, and grid (Axes properties) are not copies.
See Also
findobj
, gcf
, gca
, gco
, get
, set
Parent
property for all graphics objects
[ Previous | Help Desk | Next ]