Issue with legends/fonts and tiledlayout
6 ビュー (過去 30 日間)
古いコメントを表示
Hello, I've recenty discovered the tiledlayout() function, and it's working swimingly, with one strangely specific issue. Whenever I set the 'FontUnits' to 'normalized', I'm unable to display a legend properly. Doing everything the same with any other FontUnits, or keeping the normalized FontUnits and not showing a legend, both fix the problem.
This code demonstrates my issue (using R2020b):
%%
clc,clear
x=0:.25:30;
for figNum=1:3
figure(figNum),clf
if figNum<=2,set(figNum,'defaultAxesFontUnits','normalized','defaultAxesFontSize',.04),end
tiledlayout(1, 2, 'Padding', 'none', 'TileSpacing', 'compact');
nexttile,plot(x,sin(x),'DisplayName','Sin(x)')
if figNum>=2,legend show,end
nexttile,plot(x,cos(x),'DisplayName','Cos(x)')
if figNum>=2,legend show,end
end
0 件のコメント
回答 (1 件)
Nikhil Sonavane
2021 年 2 月 19 日
According to my understanding you are trying to mix up two different things, figure and tiledlayout are two different approches to view graphs, you don't need to use both of them. You may refer to the documentation page of tiledlayout to understand it better. Also, the syntax that you are using for legend is also incorrect. You may refer to documentation of legend as well.
参考
カテゴリ
Help Center および File Exchange で Geographic Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!