Remove spacing in matlab subplot

后端 未结 3 676
谎友^
谎友^ 2020-12-16 01:06

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


bot=imread(\'bot.jpeg         


        
3条回答
  •  [愿得一人]
    2020-12-16 01:30

    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

提交回复
热议问题