How to increase the length of the legend line?

조회 수: 130 (최근 30일)
Felix
Felix 2018년 4월 21일
답변: Afiq Azaibi 2024년 10월 9일
Hello, I would like to increase the length (not linewidth) of the line inside the legend. Does anyone has an idea? Thanks you.
t = [0:0.1:2*pi]
a = sin(t);
b = cos(t);
plot(t,a,t,b,'linewidth',3)
l = legend({'Sinus','Cosinus'},...
'location','southwest','FontName','TimesNewRoman','FontSize',20);

답변 (3개)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018년 4월 21일
편집: Walter Roberson 2020년 9월 8일
  댓글 수: 4
Luca Menegozzo
Luca Menegozzo 2020년 11월 28일
편집: Luca Menegozzo 2020년 11월 28일
The best solution to the problem without extra functions. Thank you!
Tin Truong Chanh
Tin Truong Chanh 2021년 1월 13일
thank you Arpan Sircar

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


xuewei li
xuewei li 2022년 3월 25일
leg = legend('1','2','3');
leg.ItemTokenSize = [x1,x2];

Afiq Azaibi
Afiq Azaibi 2024년 10월 9일
Starting in R2024b, you can leverage the IconColumnWidth property on legend to increase the length of the line:
t = [0:0.1:2*pi]
t = 1×63
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 2.1000 2.2000 2.3000 2.4000 2.5000 2.6000 2.7000 2.8000 2.9000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
a = sin(t);
b = cos(t);
plot(t,a,t,b,'linewidth',3)
l = legend({'Sinus','Cosinus'},...
'location','southwest','FontName','TimesNewRoman','FontSize',20);
l.IconColumnWidth = 60;

카테고리

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