Issue with legends/fonts and tiledlayout
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
Nikhil Sonavane
el 19 de Feb. de 2021
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.
Ver también
Categorías
Más información sobre Geographic Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!