Margins around histogram in subplot
조회 수: 1 (최근 30일)
이전 댓글 표시
I'm trying to make a 2x3 subplot, where the top 3 fields are merged to contain an image, and the bottom 3 fields are used for histograms for the red, green and blue layer of the image. However, there seems to be an unreasonable margin, mainly above and below each histogram. This reduces the space available for the image (which is the most important part) in the figure. So my question is this: is there anyway to reduce the size of these histogram plots? I tried removing the titles with no luck, as well as using the tightfig package.
Code
subplot(2,3,[1 2 3]);
imshow(img);
title([imageName ' with RGB histogram'], 'fontsize', 12);
subplot(2,3,4);
hist_red = hist(double(img_red),256)/max(hist(double(img_red)));
bar(hist_red);
%title('Red')
xlim([0 255]);
axis square
h = findobj(gca,'Type','patch');
set(h,'FaceColor','r','EdgeColor','r')
set(gca,'XTick',[0 255],'XTickLabel',[0 1]);
subplot(2,3,5);
hist_green = hist(double(img_green),256)/max(hist(double(img_green)));
bar(hist_green);
%title('Green')
xlim([0 255]);
axis square
h = findobj(gca,'Type','patch');
set(h,'FaceColor','g','EdgeColor','g')
set(gca,'XTick',[0 255],'XTickLabel',[0 1]);
subplot(2,3,6);
hist_blue = hist(double(img_blue),256)/max(hist(double(img_blue)));
bar(hist_blue);
%title('Blue')
xlim([0 255]);
axis square
h = findobj(gca,'Type','patch');
set(h,'FaceColor','b','EdgeColor','b')
set(gca,'XTick',[0 255],'XTickLabel',[0 1]);
tightfig;
댓글 수: 0
답변 (1개)
Bruno Pop-Stefanov
2014년 1월 22일
You can either get and set the 'OuterPosition' property programmatically for each axes, or use the custom function subaxis posted on the File Exchange.
However, subaxis doesn't seem to work for subplots that span several rows or columns like in your case. It was written in 2003. I am trying to see if I can fix that.
댓글 수: 1
Image Analyst
2014년 1월 22일
It would be better if you guys could fix subplot(). People are constantly complaining (rightfully so) about way too much wasted white space around subplots. Or at least an option to adjust how much white space/padding around the plots to have.
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Distribution Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!