Align the Legend Title to the Legend body
64 ビュー (過去 30 日間)
古いコメントを表示
Hi, How can I align the Legend Title to the Legend body (variables, etc..)? Maybe left-aligned ?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/360286/image.png)
5 件のコメント
回答 (1 件)
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')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/362554/image.jpeg)
6 件のコメント
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.
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!