# How can I change the width of a tile in a tiledlayout without changing its height?

조회 수: 4(최근 30일)
답변: Chunru 2021년 7월 28일
I'd like to decrease the width of each tile so that it looks like a vertical rectangle instead of square with vertical axis longer than horizantal. I have the following code for the figure
figure(1)
%Tile 1
nexttile
hold on
plot(theta,numer(1,:),'color',col(1),'LineWidth',2);
plot(theta,numer(2,:),'color',col(2),'LineWidth',2);
plot(theta,numer(3,:),'color',col(3),'LineWidth',2);
plot(theta,numer(4,:),'color',col(4),'LineWidth',2);
xlabel('\fontname{Arial}Scattering angle \theta(\circ)','FontSize',14,'FontWeight','normal');
ylabel('\fontname{Arial}Phase function P_{L\perp}(\theta)(sr^-^1)','FontSize',14,'FontWeight','normal');
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','Fontname','Arial','Fontsmoothing','on');
set(gca,'xgrid','on','ygrid','on','gridcolor','k');
legend('R_{eff}= 4\mum','R_{eff}= 8\mum','R_{eff}= 13\mum','R_{eff}= 18\mum','location','Northeast');% we need to calculate Reff from Rm using formaula
legend boxoff
set(gca,'yscale','log');
%yMin = floor(min(numer(i,:)));
%yMax = ceil(max(numer(i,:)));
set(gca,'xlim',[0 60],'xtick',[0:20:60],'ylim',[1e-5 1e-2],'ytick',10.^(-5:1:-2));
set(gca,'color','w','Fontsize',12,'LineWidth',1,'Fontweight','normal');
set(gca,'box','off','Fontname','Arial','Fontsmoothing','on');
set(gca,'xgrid','on','ygrid','on','gridcolor','k');
text(10,10.^(-2.22),'S_{0}=(1,-1,0,0)','Color','black','FontSize',14,'FontWeight','normal','FontName',...
'Arial')
nIDs = 1;
alphabet = ('a':'z').';
chars = num2cell(alphabet(1:nIDs));
chars = chars.';
charlbl = strcat('(',chars,')'); % {'(a)','(b)','(c)','(d)'}
text(0.05,0.95,charlbl{1},'Units','normalized','FontSize',14)

댓글을 달려면 로그인하십시오.

### 채택된 답변

Chunru 2021년 7월 28일
By changing figure size, you can achive that effect.
figure('Position', [1, 1, 600, 400])
nexttile; plot(randn(5));
nexttile; plot(randn(5));
nexttile; plot(randn(5));
figure('Position', [1, 1, 600, 200])
nexttile; plot(randn(5));
nexttile; plot(randn(5));
nexttile; plot(randn(5));

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

Dave B 2021년 7월 28일
I can think of a couple of easy options, depending on where the space should go:
Option 1, use pbaspect on the axes. This will distribute the axes (which means there's a lot of space in between them)
nexttile
plot(rand(100,1))
pbaspect([1 5 1])
nexttile
plot(rand(10,1))
pbaspect([1 5 1])
nexttile
bar(1:10)
pbaspect([1 5 1])
exportgraphics(t,'opt1.png') % picture below
Option 2: adjust the layout Position (this will keep the axes together, putting the space at one side):
nexttile
plot(rand(100,1))
nexttile
plot(rand(10,1))
nexttile
bar(1:10)
t.Position(3)=.4;
exportgraphics(t,'opt2.png') % picture below

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by