Align the Legend Title to the Legend body

조회 수: 68 (최근 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 :)
Adam Danz
Adam Danz 2020년 9월 14일
I'd be interesting in whatever you find.

댓글을 달려면 로그인하십시오.

답변 (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