The script below contains two methods of creating a legend. The first one, figure 1, gives the behaviour I want: the font is size 14, Times New Roman. However, in the second example, the font remains in the default typeface and size.
The only difference is the way the legend is initialized: in the first example the legend is initialized using "lgnd = legend(_);" with only one output varaible, whilst in the second example the legend is initialized using "[lgnd,icons,plots,txt] = legend(_);" with four output variables.
How do I change the font in the second example?
I have MATLAB 2015b.
% FIGURE 1 LEGEND IN TIMES NEW ROMAN
figure(1)% generate some plots
plot([1 1 1 1],1:4,'.','MarkerSize',2)hold onplot([2 2 2 2],1:4,'.','MarkerSize',2)plot([3 3 3 3],1:4,'.','MarkerSize',2)plot([4 4 4 4],1:4,'.','MarkerSize',2)hold offlgnd = legend('1','2','3','4');set(lgnd,'FontSize',14);set(lgnd,'FontName','Times New Roman');% FIGURE 2 LEGEND IN DEFAULT FONT
figure(2)% generate some plotsplot([1 1 1 1],1:4,'.','MarkerSize',2)hold onplot([2 2 2 2],1:4,'.','MarkerSize',2)plot([3 3 3 3],1:4,'.','MarkerSize',2)plot([4 4 4 4],1:4,'.','MarkerSize',2)hold off[lgnd,icons,plots,txt] = legend('1','2','3','4');set(lgnd,'FontSize',14);set(lgnd,'FontName','Times New Roman');
Edit: Added the pictures as attachments to illustrate.
Best Answer