How to copy a plot
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Arun
am 20 Dez. 2013
Kommentiert: José-Luis
am 20 Dez. 2013
How can I copy a plot into a new figure. Then on the new figure plot a vector on a second y axis. I have tried to use the copyobj and plotyy. However I may been using incorrect syntax.
Update
The original figure is produced by a function. What would be the syntax in this case?
0 Kommentare
Akzeptierte Antwort
José-Luis
am 20 Dez. 2013
fH(1) = figure(1);
fH(2) = figure(2);
fH(3) = figure(3);
figure(fH(1));
lH = plot(rand(10,2));
aH = ancestor(lH(1),'axes');
figure(fH(2));
aH(2) = axes;
copyobj(lH(1),aH(2)); %copy line to axes
copyobj(aH(1),fH(3)); %copy axes to figure
1 Kommentar
José-Luis
am 20 Dez. 2013
%Some figure you know nothing about
plot(rand(10,2)); %click it to make it the active figure
%Find its handle
aH = gca;
fH = ancestor(aH,'fig');
fH(2) = figure(2); %Figure you want to copy the stuff to
%Copy axes or see my previous code to copy lines, store its handle
aH(2) = copyobj(aH,fH(2));
%create new axes
aH(3) = axes('Position',get(aH(2),'Position'));
linkaxes(aH(2:3),'x');
%Plot your new stuff
plot(1:10);
%Making them look nice
set(aH(3),'YAxisLocation','right','Color','none');
set(aH(2:3),'box','off');
Please accept an answer if it helps you.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Two y-axis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!