Construct a copy of the graphic objects associated with the handles horig and return new handles hnew to the new objects.
If a parent handle hparent (root, figure, axes, or hggroup) is specified, the copied object will be created as a child of hparent.
If horig is a vector of handles, and hparent is a scalar,
then each handle in the vector hnew has its "Parent"
property
set to hparent. Conversely, if horig is a scalar and
hparent a vector, then each parent object will receive a copy of
horig. If horig and hparent are both vectors with the
same number of elements then hnew(i)
will have parent
hparent(i)
.
See also: struct2hdl, hdl2struct, findobj.
The following code
hobj = clf; set (hobj, "name", "Original", "numbertitle", "off"); hold on; x = 1:10; y = x.^2; dy = 2 * (.2 * x); y2 = (x - 3).^2; hg = errorbar (x, y, dy); set (hg, "marker", "^", "markerfacecolor", rand (1,3)); plot (x, y2, "ok-"); legend ("errorbar", "line"); drawnow (); pos = get (hobj, "position"); scrn = get (0, "screensize"); set (hobj, "position", [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); hnew = copyobj (hobj); drawnow (); set (hnew, "name", "Copyobj"); drawnow (); set (hnew, "position", [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow ();
Produces the following figures
Figure 1 | Figure 2 |
---|---|
The following code
hobj = clf; set (hobj, "name", "Original", "numbertitle", "off"); subplot (2,2,1); hold on; contourf (rand (10, 10)); colorbar (); subplot (2,2,2); quiver (rand (10, 10), rand (10, 10)); subplot (2,2,3); colormap (jet (64)); hold on; sombrero (); colorbar ("peer", gca, "NorthOutside"); subplot (2,2,4); imagesc (rand (30, 30)); text (15, 15, "Rotated text", ... "HorizontAlalignment", "Center", "Rotation", 30); drawnow (); pos = get (hobj, "position"); scrn = get (0, "screensize"); set (hobj, "position", [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow (); hnew = copyobj (hobj); drawnow (); set (hnew, "name", "Copyobj"); drawnow (); set (hnew, "position", [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); drawnow ();
Produces the following figures
Figure 1 | Figure 2 |
---|---|
Package: octave