Vertical blank space in tiledlayout compact
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dear all
I am plotting the following:
u1=figure('visible','off','units','pixels','position',[0 0 1920 1080]);
t=tiledlayout(2,2,'Padding','compact');
title(t,['Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $\mathbf{H}=0$';'';''],'FontSize',18,'interpreter','latex');
ax1=nexttile;
uimagesc(space_x,space_y,mx);
axis xy;
clim([-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
colormap(ax1,bluewhitered(256));
box on;
clr1=colorbar('YTick',[-round(max([abs(max(max(mx))) abs(min(min(mx)))]),2) -round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) 0 round(max([abs(max(max(mx))) abs(min(min(mx)))])/2,2) round(max([abs(max(max(mx))) abs(min(min(mx)))]),2)]);
set(clr1,'TickLabelInterpreter','latex');
xlabel('$a$-{\it th} spatial direction, $a \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel('$b$-{\it th} spatial direction, $b \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel(clr1,'$a$-{\it th} magnetization component, $m_a$','Interpreter','Latex','FontSize',16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',15);
ax2=nexttile;
uimagesc(space_x,space_y,my);
clim([-max([abs(max(max(my))) abs(min(min(my)))]) max([abs(max(max(my))) abs(min(min(my)))])]);
colormap(ax2,bluewhitered(256));
axis xy;
box on;
clr2=colorbar('YTick',[-max([abs(max(max(my))) abs(min(min(my)))]) -max([abs(max(max(my))) abs(min(min(my)))])/2 0 max([abs(max(max(my))) abs(min(min(my)))])/2 max([abs(max(max(my))) abs(min(min(my)))])]);
set(clr2,'TickLabelInterpreter','latex');
xlabel('$a$-{\it th} spatial direction, $a \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel('$b$-{\it th} spatial direction, $b \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel(clr2,'$b$-{\it th} magnetization component, $m_b$','Interpreter','Latex','FontSize',16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',15);
ax3=nexttile;
uimagesc(space_x,space_y,mz);
box on;
axis xy;
clim([-max([abs(max(max(mz))) abs(min(min(mz)))]) max([abs(max(max(mz))) abs(min(min(mz)))])]);
colormap(ax3,bluewhitered(256));
clr3=colorbar('YTick',[-max([abs(max(max(mz))) abs(min(min(mz)))]) -max([abs(max(max(mz))) abs(min(min(mz)))])/2 0 max([abs(max(max(mz))) abs(min(min(mz)))])/2 max([abs(max(max(mz))) abs(min(min(mz)))])]);
set(clr3,'TickLabelInterpreter','latex');
xlabel('$a$-{\it th} spatial direction, $a \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel('$b$-{\it th} spatial direction, $b \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel(clr3,'$z$-{\it th} magnetization component, $m_z$','Interpreter','Latex','FontSize',16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',15);
ax4=nexttile;
uimagesc(space_x,space_y,total_magnetization);
box on;
axis xy;
clim([0 max(max(total_magnetization))]);
colormap(ax4,cmap);
clr4=colorbar('YTick',[0 max(max(total_magnetization))/5 2*max(max(total_magnetization))/5 3*max(max(total_magnetization))/5 4*max(max(total_magnetization))/5 max(max(total_magnetization))]);
set(clr4,'TickLabelInterpreter','latex');
xlabel('$a$-{\it th} spatial direction, $a \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel('$b$-{\it th} spatial direction, $b \, \, \left( \mathrm{nm} \right)$','FontSize',15,'interpreter','latex');
ylabel(clr4,'Magnetization vector modulus, $\left| \mathbf{m} \right|$','Interpreter','Latex','FontSize',16);
xlim([0 300]);
xticks([0:50:300]);
ylim([0 100]);
yticks([0:20:100]);
pbaspect([1 1/3 1]);
xtickangle(0);
set(gca,'TickLabelInterpreter','latex','FontSize',15);
set(gcf,'color','white');
set(gca,'Units','normalized');
set(u1,'Units','Inches');
posu1=get(u1,'Position');
set(u1,'PaperPositionMode','Auto','PaperUnits','Inches','PaperSize',[posu1(3),posu1(4)]);
and the plot looks like:
As you can see there is some vertical unnecessary space between the two horizontal stacks of plots. I would like to reduce it to be able to put the general title "Bilayer..." far enough from the top plots.
Any ideas?
0 Kommentare
Antworten (4)
Steve Eddins
am 6 Aug. 2024
Trying setting TileSpacing to compact or tight.
t=tiledlayout(2,2,'Padding','compact','TileSpacing','compact');
Or:
t=tiledlayout(2,2,'Padding','compact','TileSpacing','tight');
Also, since you need room for an overall title, you might want to set Padding to loose instead of compact:
t=tiledlayout(2,2,'Padding','loose','TileSpacing','compact');
0 Kommentare
Romain
am 6 Aug. 2024
Hello,
At line 3 (definition of title), change the brackets around the title by curly braces:
{'Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $\mathbf{H}=0$';'';''}
That's how you create subtitles in the title function, here you have 2 lines of subtitles and you can add as much as you want.
0 Kommentare
Adam Danz
am 6 Aug. 2024
> As you can see there is some vertical unnecessary space between the two horizontal stacks of plots. I would like to reduce it to be able to put the general title "Bilayer..." far enough from the top plots
If the main goal is to insert space between the global title and the first row of axes, you can add empty rows of text under the title. It looks like you were heading in that direction based on the rows of empty characters at the end of your title string. But those empty characters are trimmed.
title(t,['Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $\mathbf{H}=0$';'';''],'FontSize',18,'interpreter','latex');
title(t,['Bilayer. Monte Carlo, $15$ million steps. $T=2$ K, $\mathbf{H}=0$',newline(),newline()],'FontSize',18,'interpreter','latex');
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!