How do I change the font size in my legend?
4.046 views (last 30 days)
Show older comments
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');
Accepted Answer
MathWorks Support Team
on 2 Sep 2020
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)
4 Comments
Jordan Fliss
on 4 Dec 2020
This problem sounds like the one I am experiencing now. After I changed the setting I saved the figure as a .fig, closed the figure window, then loaded the figure again (by simply double clicking it). After the figure reloaded my legend font changes were implemented.
More Answers (3)
Mukesh Jadhav
on 9 Oct 2016
Here you go :
h = legend('x','y','z');
set(h,'FontSize',12);
2 Comments
Jamil Khan
on 26 Oct 2020
legend('x','y','z'),set(legend,'fontsize',12);
this works aswell, you dont have set the legend as an object
Samson Msgna
on 23 Mar 2018
How can we solve Error using CreateDatabase (line 22) Not enough input arguments.
Error using EigenfaceCore (line 20) Not enough input arguments.
1 Comment
Walter Roberson
on 26 Mar 2018
This appears to refer to
//www.tatmou.com/matlabcentral/fileexchange/17032-pca-based-face-recognition-system
You need to pass the path of the directory containing the data to EigenfaceCore . See the example.m file for example.
See Also
Categories
下载188bet金宝搏
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!