How can I adjust the space between each subplot for a 5*3 subplots setup?
248 次查看(过去 30 天)
显示 更早的评论
I know I need to have a format like this below but I could not figure out what are the values should be in after the 'position' parameter.
Also, I want to keep the title for each subplot.
ESPECIALLY, I don't want the vertical distance between each column of the subplot so large. It seems the distance between each column of the subplot becomes larger as the number of rows of subplots get larger.
Also its ok that if I can edit and change the space after I saved the figure as a .fig file. But not sure how.
Thank you for your hints/helps in advance.
subplot(5,3,1);imshow(a1_1,[]);title('(a1)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,2);imshow(a2_1,[]);title('(a2)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,3);imshow(a3_1,[]);title('(a3)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,4);imshow(b1_1,[]);title('(b1)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,5);imshow(b2_1,[]);title('(b2)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,6);imshow(b3_1,[]);title('(b3)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,7);imshow(c1_1,[]);title('(c1)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,8);imshow(c2_1,[]);title('(c2)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,9);imshow(c3_1,[]);title('(c3)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,10);imshow(d1_1,[]);title('(d1)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,11);imshow(d2_1,[]);title('(d2)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,12);imshow(d3_1,[]);title('(d3)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,13);imshow(e1_1,[]);title('(e1)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,14);imshow(e2_1,[]);title('(e2)');set(gca,'xtick',[],'ytick',[])
subplot(5,3,15);imshow(e3_1,[]);title('(e3)');set(gca,'xtick',[],'ytick',[])
ha=get(gcf,'children');
set(ha(1),'position',[ ])
set(ha(2),'position',[ ])
set(ha(3),'position',[ ])
set(ha(4),'position',[ ])
set(ha(5),'position',[ ])
set(ha(6),'position',[ ])
set(ha(7),'position',[ ])
set(ha(8),'position',[ ])
set(ha(9),'position',[ ])
set(ha(10),'position',[ ])
set(ha(11),'position',[ ])
set(ha(12),'position',[ ])
set(ha(13),'position',[ ])
set(ha(14),'position',[ ])
set(ha(15),'position',[ ])
5 个评论
回答(2 个)
Matt J
2023-10-15
编辑:Matt J
2023-10-15
The subaxis function in this FEX download
offers specific settings for horizontal and vertical spacing.
n=4;
figure;
for i=1:n
subaxis(1,n,i, 'SpacingHoriz',0);
imagesc(phantom(128)); axis image off
colormap(gray)
end
figure;
for i=1:n
subaxis(1,n,i, 'SpacingHoriz',0.05);
imagesc(phantom(128)); axis image off
colormap(gray)
end
0 个评论
Matt J
2023-10-15
编辑:Matt J
2023-10-15
n=4;
%1x4
figure;
t=tiledlayout(1,n,'TileSpacing','tight');
for i=1:prod(t.GridSize)
nexttile
imagesc(phantom(128)); axis image off
colormap(gray)
end
%3x4
figure;
t=tiledlayout(3,n,'TileSpacing','tight');
for i=1:prod(t.GridSize)
nexttile
imagesc(phantom(128)); axis image off
colormap(gray)
end
1 个评论
Matt J
2023-10-15
移动:Matt J
2023-10-15
As I said, the distance between each column of the subplot becomes larger as the number of rows of subplots get larger.
It's because the tiledlayout expands elastically to fill the figure window. If you narrow the window, you should see the thumbnails compress together.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!