I encountered a problem where the legend box is not automatically sized as the font size changes.
x = [1 4 6 8 0 2 4 7 8]
plot(x)
lngd = legend('Nov 5, 2010 09:00 - 09:01');
set(lngd, 'interpreter','latex', 'fontsize', 10);
generates the following graph

My two problems are
set(lngd, 'interpreter','latex', 'fontsize', 10, [0 0 10 10]); to enlarge the box, but no luck.set(lngd, 'southeast', 'interpreter','latex', 'fontsize', 10);, but no luck.How may I fix these two problems?
Is there any particular reason that you use 'interpreter', 'latex'? It seems to mess with the boxing of the legend for some MATLAB. You can try to manually change the legend box position and size by setting the Position variable.
x = [1 4 6 8 0 2 4 7 8]
plot(x)
lngd = legend('Nov 5, 2010 09:00 - 09:01');
set(lngd, 'fontsize', 10, 'interpreter','latex','Position', [0.55,0.15,0.35,0.08]);
The Position vector is [left,bottom,width,height] of the box in 0~1 range.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With