Removing deadspace in subplots while retaining title & labels

前端 未结 5 1911
滥情空心
滥情空心 2021-01-03 04:08

Hi I have a problem in matlab I want to create a figure containing 10 subplots. in 2X5 orientation. But the problem is that I want to reduce the deadspace area between them

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-03 04:42

    close all
    figure,set(gca,'Color','none')
    subplot('Position',[0.025 0.51  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    imshow(I);hold on; axis off;
    contour((BW(:,:,1)), [0 0], 'r','LineWidth',2);
    hold off;title('1st curve','FontSize',12);h=xlabel('(a)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*1 0.51  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    imshow(I);hold on; axis off;
    contour((BW(:,:,2)), [0 0], 'r','LineWidth',2);
    hold off;title('2nd curve','FontSize',12);h=xlabel('(b)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*2 0.51  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    imshow(I);hold on; axis off;
    contour((BW(:,:,3)), [0 0], 'r','LineWidth',2);
    hold off;title('3rd curve','FontSize',12);h=xlabel('(c)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*3 0.51  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    imshow(I);hold on; axis off;
    contour((BW(:,:,4)), [0 0], 'r','LineWidth',2);
    hold off;title('4th curve','FontSize',12);h=xlabel('(d)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*4 0.51  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    imshow(I);hold on; axis off;
    contour((BW(:,:,5)), [0 0], 'r','LineWidth',2);
    hold off;title('5th curve','FontSize',12);h=xlabel('(e)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    
    subplot('Position',[0.025 0.03  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    seg = phi0(:,:,1)<=0;imshow(seg);
    h=xlabel('(f)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*1 0.03  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    seg = phi0(:,:,2)<=0;imshow(seg);
    h=xlabel('(g)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*2 0.03  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    seg = phi0(:,:,3)<=0;imshow(seg);
    h=xlabel('(h)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*3 0.03  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    seg = phi0(:,:,4)<=0;imshow(seg);
    h=xlabel('(i)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    subplot('Position',[0.025+0.19*4 0.03  0.19 0.48]);get(gca,'position');set(gca, 'XTick', []);set(gca, 'YTick', []);
    seg = phi0(:,:,5)<=0;imshow(seg);
    h=xlabel('(j)','FontSize',12);
    s=get(h,'Position');
    s(2)=s(2)-28;
    set(h,'Position',s);
    

    Thanks everybody I got the correct answer. I changed my code a bit.

    This was the answer I got :

    enter image description here

提交回复
热议问题