How to workaround the plotyy copyobj error?

1 次查看(过去 30 天)
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 个评论
dpb
dpb 2014-10-2
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 2014-10-2
Thx, for your infos. I run R2014a so there the problem still remains... Lets see what the support suggests...

请先登录,再进行评论。

采纳的回答

Joseph Cheng
Joseph Cheng 2014-10-2
编辑:Joseph Cheng 2014-10-2
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 个评论
sejo
sejo 2014-10-2
Thx for your workaround. I´ll try if that is working for me...
sejo
sejo 2014-10-17
编辑:sejo 2014-10-17
Finally managed to do this task. Used the workaround of plotting the data again in the new figure.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Two y-axis 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by