Align the Legend Title to the Legend body

66 次查看(过去 30 天)
Sim
Sim 2020-9-14
评论: Sim 2020-9-23
Hi, How can I align the Legend Title to the Legend body (variables, etc..)? Maybe left-aligned ?
  5 个评论
Sim
Sim 2020-9-14
编辑:Sim 2020-9-14
Thanks a lot! Just submitted to the MATLAB support :)

请先登录,再进行评论。

回答(1 个)

Ayush Gupta
Ayush Gupta 2020-9-18
The legend title is by-default left aligned to legend body. Refer to the code below which generates the following picture and read the documentation on how to add legend title, here.
x = linspace(0,pi);
y1 = cos(x);
plot(x,y1)
hold on
y2 = cos(2*x);
plot(x,y2)
hold off
lgd = legend('cos(x)','cos(2x)');
title(lgd,'My Legend Title')
  6 个评论
Adam Danz
Adam Danz 2020-9-23
I've checked since I made that comment and legend titles are not supported with the updated features.
In fact, I wrote a Community Highlights about these new features.
Title alignment is controlled by the new "TitleHorizontalAlignment" property of axes. Legends still do not have such a property.
Sim
Sim 2020-9-23
Oh cool, thanks a lot for highlighting that feature... So, if not working for the Legends, my MATLAB ticket opening was worth it :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by