handle to the addaxis with many output arguements can not run?
5 views (last 30 days)
Show older comments
Hello everyone,
I have three lines subplotted in one figure by using the great addaxis tool.
Everything goes well except that the order of entries in legend is not what I want. I need to change the entries' order displayed in legend from "black line,red line,blue line" (as is the outcome in the figure) to "blue line,black line,red line" without changing the plotting order. I tried the following codes but got error hint as below.
The code is :
for ii=1:length(ending_cell)
HOR=1:1:10;
var={'b','l','l','l','l','l','l',};
var1={'b_t','l_t','l_t','l_t','l_t','l_t','l_t',};
figure('Name',strcat(ending_cell{1,ii},'1'))
for jj=1:length(var)
subaxis(3,3,jj,'MarginRight',0.3,'MarginLeft',0.3,'SpacingHoriz',0.1,'SpacingVert',0.1)
eval(['irf5.' var{1,jj},ending_cell{1,ii}]);
eval(['irf0.' var{1,jj},ending_cell{1,ii}]);
eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
hold on
p1=plot(HOR,eval(['irf5.' var{1,jj},ending_cell{1,ii}]),'Linestyle','-','Color','k');
p2=addaxis(HOR,eval(['irf10.' var{1,jj},ending_cell{1,ii}]),'Linestyle','--','Color','r');
p3=addaxis(HOR,eval(['irf1.' var{1,jj},ending_cell{1,ii}]),'Linestyle','-.','Color','b');
p2_child = get(p2,'Children');
p3_child = get(p3,'Children');
title([var1{1,jj}])
end
ylabels = {'u=5', 'u=10', 'u=1'};
s1L=legend([p3_child p1 p2_child],ylabels,'Orientation','horizontal','Location','SouthOutside','NumColumns',3);
s1P = [0.5 0.02 0.03 0.03];
set(s1L,'Position', s1P,'Units', 'normalized');
end
The error hint is :
Error using addaxis
Too many output arguments.
Error in plotyy1_all (line 4)
p2=addaxis(HOR,eval(['irf1.' var{1,jj},ending_cell{1,ii}]),'Linestyle','--','Color','r');
Does it mean that the addaxis with such arguements can not be used with handle? I saw some successful example using handle to addaxis with simpler arguements in the forum. Is there any way to deal with this? Could anyone give me some help? Thank you so much.
Best,
LIU
0 Comments
Answers (0)
See Also
Categories
Find more on Create Fixed-Point Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!