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;

回答(1 个)

Bruno Pop-Stefanov
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
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 CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by