Issue with legends/fonts and tiledlayout
조회 수: 3 (최근 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에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!