Create complex legend with two string including variables values.
2 次查看(过去 30 天)
显示 更早的评论
I'm trying to add a legend to a plot where multiple variable are plotted in two y axes. I want to highlight two values on this plot (concerning only one axis) and add a legend about only this points.
here is the code:
p5=plot(U(kk1),real(sol(kk1,:)),'d','MarkerSize',15,'Color','b');
p6=plot(U(kk2),real(sol(kk2,:)),'o','MarkerSize',15,'Color','b');
str_lgd1 =['Real eigenvalue for U = ',...
num2str(U_stop(1)), ' m/s' char(10) 'Re(p) = ', ...
num2str(abs(real(sol(kk1,1))))];
str_lgd2 = ['Real eigenvalue for U = ',...
num2str(U_stop(2)), ' m/s' char(10) 'Re(p) = ', ...
num2str(abs(real(sol(kk2,1))))];
lgd=legend([p5 p6],str_lgd1,str_lgd2);
p5 and p6 are the objects I want to add the legend. str_lgd1 and str_lgd2 are the string I want to be displayed. The error is:
Operands to the || and && operators must be convertible to logical scalar values.
Error in legend (line 189)
all(isgraphics(args{1})) % legend(children,strings,...)
Error in Es4 (line 244)
lgd=legend([p5 p6],{str_lgd1,str_lgd2});
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!