title shifted into figure box
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am running a for loop to produce several figures at once in some of the figures the title gets shifted into the figure box and is obstructed by some of my bars.
Here is the code I am using:
for i = 1:6
X(1) = ave_dur_spei(1,i);
X(2:7) = ave_dur_spei_gcm_ann(1:6,i);
bar_h=bar(X);
bar_child=get(bar_h,'Children');
set(bar_child,'CData',X);
set(gca,'XTickLabel',{'Historical';'cnrm-cm3';'gfdl-cm2-1';'miroc3-2-med';'mpi-echam5';'ncar-ccsm3';'ncar-pcm1'},'fontsize',18)
xticklabel_rotate
ylabel('average duration (months)','fontsize',18)
title([num2str(x(i)),'-month SPEI: Austin, NV (duration below 90th percentile)'],'fontsize',14)
set(gca,'fontsize',18)
refline(0,X(1))
saveas(gcf,['austin_',num2str(x(i))],'png')
close gcf
end
The error only occurs when i = 3, 4, and 5...
Can anyone help me?
Thanks, Dan
3 comentarios
Jan
el 13 de Jul. de 2011
How strange that "close gcf" works, because this means "close('gcf')", but Matlab understands what the user wants - a first version of feature('dwim').
Respuesta aceptada
Jan
el 13 de Jul. de 2011
TITLE creates a TEXT object with 'data' units. The position of the title is influenced by the axes' fontsize. Solution: Set the axes' fontsize at first and use 'normlized' units:
set(gca, 'fontsize', 18);
title([num2str(x(i)), '-month etc.'], 'fontsize', 14, ...
'units', 'normalized', 'Position', [0.5, 1.02])
2 comentarios
Jan
el 13 de Jul. de 2011
The YLabel considers the width of the YTickLabels, which is not easy to control. But it works equivalent to the title.
You can look in the source of ylabel.m.
Más respuestas (0)
Ver también
Categorías
Más información sobre Labels and Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!