Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
715 views
in Technique[技术] by (71.8m points)

image - Remove spacing in matlab subplot

How should i remove the empty space between these images?i need to combine all these images without any space.


bot=imread('bot.jpeg');

for i= 1:25
subplot(5,5,i),imshow(bot);
end

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to specify axes' 'Position' property when you create them with subplot.

Also, you have to adjust figure aspect ratio to match that of the image, so that all figures fit without vertical or horizontal space.

If you show a different image in each subplot, all images should have the same aspect ratio, otherwise it's not possible for them to fit in the figure without empty spaces.

bot = imread('peppers.png');
for i= 1:25
    subplot('Position',[(mod(i-1,5))/5 1-(ceil(i/5))/5 1/5 1/5])
    imshow(bot); %// or show a different image on each subplot
end
p = get(gcf,'Position');
k = [size(bot,2) size(bot,1)]/(size(bot,2)+size(bot,1));
set(gcf,'Position',[p(1) p(2) (p(3)+p(4)).*k]) %// adjust figure x and y size

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...