Issue with legends/fonts and tiledlayout
7 次查看(过去 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!