How can I change the width of a tile in a tiledlayout without changing its height?
274 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Wiqas Ahmad
am 28 Jul. 2021
Beantwortet: Chunru
am 28 Jul. 2021
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)
t = tiledlayout(1,3,'TileSpacing','Compact','Padding','Compact');
%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)
0 Kommentare
Akzeptierte Antwort
Chunru
am 28 Jul. 2021
By changing figure size, you can achive that effect.
figure('Position', [1, 1, 600, 400])
t = tiledlayout(1,3,'TileSpacing','Compact','Padding','Compact');
nexttile; plot(randn(5));
nexttile; plot(randn(5));
nexttile; plot(randn(5));
figure('Position', [1, 1, 600, 200])
t = tiledlayout(1,3,'TileSpacing','Compact','Padding','Compact');
nexttile; plot(randn(5));
nexttile; plot(randn(5));
nexttile; plot(randn(5));
0 Kommentare
Weitere Antworten (1)
Dave B
am 28 Jul. 2021
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)
tiledlayout(1,3,'TileSpacing','Compact','Padding','Compact')
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):
t = tiledlayout(1,3,'TileSpacing','Compact','Padding','Compact')
nexttile
plot(rand(100,1))
nexttile
plot(rand(10,1))
nexttile
bar(1:10)
t.Position(3)=.4;
exportgraphics(t,'opt2.png') % picture below
0 Kommentare
Siehe auch
Kategorien
Mehr zu Axis Labels 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!