MATLAB: Does the legend not resize when I modify the legend font size in MATLAB 7.0 (R14)

boxfontlegendMATLABr14resize

I create a simple plot with a legend using the following code:
plot(rand(4))
h_legend=legend('One','Two','Three','Four');
get(h_legend,'Position')
h_text = findobj(h_legend,'type','text');
set(h_text,'FontUnits','points','FontSize',4)
get(h_legend,'Position')
The legend box does not change to fit the text.

Best Answer

There is a bug in MATLAB 7.0 (R14) that prevents the legend box size from being properly updated when accessed in the manner shown.
To work around this issue, update the legend font size by using the legend handle directly:
set(h_legend,'FontSize',4)
This will update the legend box size automatically.