How to workaround the plotyy copyobj error?

6 Ansichten (letzte 30 Tage)
sejo
sejo am 2 Okt. 2014
Bearbeitet: sejo am 17 Okt. 2014
Hy, I have the same question like this question. But unfortunately the linke for the workarond is removed.
Can anyone help me how to copy both axes of the ployy to another figure?
  2 Kommentare
dpb
dpb am 2 Okt. 2014
Seems TMW has removed everything prior to ca. R14 from the bug report search engine. Unfortunately, the symptoms seem to remain here w/ R2012b; I presume since the original posting dates from 2004 they probably also are still around in most recent releases as well...
Which release are you running and do you have support? Looks like an official bug report is due again to re-raise the issue if others can duplicate the problem still.
Maybe Steven L will stumble by and by dint of being inside TMW can resurrect the previous workaround or recalls enough to regenerate it.
sejo
sejo am 2 Okt. 2014
Thx, for your infos. I run R2014a so there the problem still remains... Lets see what the support suggests...

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Joseph Cheng
Joseph Cheng am 2 Okt. 2014
Bearbeitet: Joseph Cheng am 2 Okt. 2014
This is a bit lengthy but you can try something like this where you save the data in userdata if the original data is nolonger available. then copy each parameter as such.
%generate some plots
x = 0:0.01:20;
y1 = 200*exp(-0.05*x).*sin(x);
y2 = 0.8*exp(-0.5*x).*sin(10*x);
%create new fig
figh1 = figure;
plotyy1 = plotyy(x,y1,x,y2);
%save the data in userData incase you don't have it for the new plot
set(plotyy1(1),'UserData',[x;y1]);
set(plotyy1(2),'UserData',[x;y2]);
set(plotyy1(1),'Ylim',[-500 500]);
set(plotyy1(2),'Ylim',[0 1]);
%create figure to copy to
figh2 = figure;
%reclaim the data if lost but figure is still there
reclmXY1 = get(plotyy1(1),'userData');
reclmXY2 = get(plotyy1(2),'userData');
%plot the two as a new yy
plotyy2= plotyy(reclmXY1(1,:),reclmXY1(2,:),reclmXY2(1,:),reclmXY2(2,:));
%get the parameters names for the axes
param = fieldnames(get(plotyy1(1)));
for ind = 1:2 %loop through the two plots
for jind=1:length(param)
try,
%just for debug to see what properties are set
disp(param(jind))
temp = get(plotyy1(ind),param(jind)); %can be inside the set()
if ~strcmp(param(jind),'Parent'); %skip designating parent
set(plotyy2(ind),param(jind),temp) %copy axes param
end
end
end
end
There could be an easier way to copy/set all the parameters except for the parent for each handle object but cannot come up with it at the moment.
  2 Kommentare
sejo
sejo am 2 Okt. 2014
Thx for your workaround. I´ll try if that is working for me...
sejo
sejo am 17 Okt. 2014
Bearbeitet: sejo am 17 Okt. 2014
Finally managed to do this task. Used the workaround of plotting the data again in the new figure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

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!

Translated by