You can use copyobj
h = plot([1:0.2:10]) xx=get(h) figure copyobj(h,gca)
This duplicates the graph to a new digit.
See: http://www.mathworks.com/help/matlab/ref/copyobj.html
UPDATE
I don't think you can create directly from the xx structure by trying to do this:
h = plot([1:0.2:10]) xx=get(h) h2 = plot(0,0) set(h2,xx)
Gives an error message
Error using graph2d.lineseries/set Changing the 'Annotation' property of line is not allowed.
You will need to manually set some property values:
h = plot([1:0.2:10]) xx=get(h) figure h2 = plot(0.0) names = fieldnames(xx); fieldCount = size(names,1); protectedNames = {'DisplayName' 'Annotation' 'BeingDeleted' 'Type' 'Parent'} for i = 1:fieldCount name = names{i}; if ( ismember(protectedNames, name) == false ) set(h2, name, getfield(xx,name)) end end yy=get(h2)
ccook source share