MATLAB: How to change the font size in the legend

axesboxfontfontsizelegendMATLABsize;

How do I change the font size of the labels in my legend? For example, how do I make the font size of the ‘One’, ‘Two’, ‘Three’, ‘Four’ labels bigger in my plot?
plot(rand(4))
lgd=legend('One','Two','Three','Four');

Best Answer

You can change the font size for a MATLAB legend by setting the 'FontSize' property of the Legend object.
For example, plot four lines. Create a legend and assign the Legend object to the variable 'lgd'. Then, use dot notation to access the 'FontSize' property and set the value to 14 points.
plot(rand(4))
lgd = legend('One','Two','Three','Four');
lgd.FontSize = 14;
Alternatively, you can specify the 'FontSize' property using a name-value pair argument in the 'legend' command. When including name-value pair arguments, include the legend labels in a cell array. For example:
legend({'One','Two','Three','Four'},'FontSize',14)