2

I use some things from this question get-rid-of-the-white-space-around-matlab-figures-pdf-output to get rid of the white space when saving figure plots and images. This works fine, but my problem is when I use commands like "axis square" or "axis image". Ivt sets TightInset property of corresponding axes to 0 in "y" direction. I mean when I use this:

inset=get(a,'TightInset');

second and fourth numbers in "inset" are always zero, even if I set title and x-label. So in the end I don't see plot titles and x-labels.

Can I fix it somehow? So far I do it manually by adding some suitable number, but it is not convenient.

EDIT: Some more code for example. It displays two histograms.

h=figure;
subplot(121)
bar(bins,histogram1,'hist');
axis square
title('Historgram 1');
xlabel('Intensity');
ylabel('Pixel count');
set(gca,'xlim',[0 1])

subplot(122)
bar(bins,histogram_out,'hist');
axis square
title('Histogram 2');
set(gca,'xlim',[0 1])
xlabel('Intensity');
ylabel('Pixel count');

and if I call

a=get(h,'Children');
for i=1:length(a)
    inset=get(a(i),'TightInset');
%...some stuff here
end

those y-related numbers in inset are zeros. If I comment axis square and do this, then inset are correct and it does what I need.

Community
  • 1
  • 1
xyann00
  • 25
  • 4
  • We need some more information/code, what plot command are you using? Try `set(a,'LooseInset',get(a,'TightInset'));` and make sure you do it AFTER `axis square` or similar – Robert Seifert May 05 '14 at 13:32

1 Answers1

0

As far as I know when you use 'TightInset' you'll get only the graph or image, axis will be removed. I downloaded a function from mathworks file exchange 'saveTightfigure.m' to solve a similar problem. But I did not needed axes. If you need axes may be you can edit limits set inside the function. I mean you can give a little more space at left and bottom for keeping the axes.

akhilc
  • 181
  • 4
  • 19
  • this function `savetightfigure.m` doesn't work with axis square/image or similar. That's why I do it my way. But I would like tightInset property to work. – xyann00 May 05 '14 at 15:40