How to convert long to scientific e format in plots legend?
8 次查看(过去 30 天)
显示 更早的评论
txt = ['lambda = ',num2str(lambda(check))];
plot(1:100, abs(Arec(:,2000)),'DisplayName',txt)% capon
legend show
How to change the long format to scieitific e, like 1e6 in legend?
0 个评论
回答(1 个)
Bjorn Gustavsson
2022-6-10
You could be a bit more explicit in the call to legend:
txt = ['lambda = ',num2str(lambda(check))];
ph = plot(1:100, abs(Arec(:,2000))); % ,'DisplayName',txt); % capon
leg_str = sprintf('lambda = %3.3g',lambda(check));
legend(ph,leg_str)
HTH
2 个评论
Bjorn Gustavsson
2022-6-10
True, but explicitly calling legend with the plot-handles has additional benefits in terms of what to include, which is not necessary in this case but will eventually pop up.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!