How can I reduce the distance between the axis and their title?

3 次查看(过去 30 天)
my program is so that the user enters a figure,and the program should make it smaller. I'm almost done with the program,the only problem is that the distance between the axis and their title doesn't become smaller as the whole figure becomes smaller. How can I reduce the distance between the axis and their title?
this is my code:
h=hgload(name);
set(gcf,'paperunits','centimeters');
set(gcf,'paperposition',[w(1) w(2) a(1) a(1)*a(2)]);
textobj=findobj('type','text');
set(textobj,'fontunits','points');
set(textobj,'fontsize',w(3));
set(findall(gcf,'property','fontsize'),'fontsize',w(3));
set(gca,'fontsize',w(3));
set(findall(gca,'type','text'),'fontsize',w(3));
set(findall(gcf,'type','text'),'fontsize',w(3));
new_name=strrep([pathName name],'.fig','.png');
child=get(gcf,'children');
for y=1:length(child)
chi=child(y);
set(chi,'fontsize',w(3));
end

回答(1 个)

dpb
dpb 2014-1-21
The position is set by the 'position' property and changing fontsize doesn't affect it (as you've noticed). You'll have to retrieve the various label position vectors and mung on them as needed to achieve the effect desired.
As an aside, it would likely be simpler if you were to save handles to the various objects as they're created and thus could access their properties directly thru the handle rather than all the "handle-diving" you're currently doing looking up stuff...

标签

Community Treasure Hunt

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

Start Hunting!

Translated by